override protected void Update()
    {
        body.velocity        = velocityTracker.Velocity;
        body.angularVelocity = velocityTracker.AngularVelocity;
        base.Update();

        for (int i = 0; i < touchingMaterials.Count; ++i)
        {
            if (holding.Contains(touchingMaterials[i].GetComponent <Interactable>()))
            {
                float swingAmp = touchingMaterials[i].GetSwingUpdateAmplitude(Time.deltaTime);
                if (swingAmp > 0f)
                {
                    HapticHandler.Blip(node, swingAmp, false);
                }
                continue;
            }
            else if (HapticHandler.DoingPulse(node))
            {
                continue;
            }

            float amp = touchingMaterials[i].GetStayTouchAmplitude(body.velocity);
            if (amp > 0f)
            {
                HapticHandler.Blip(node, amp, false);
            }
        }
    }
    protected override void OnTriggerExit(Collider other)
    {
        base.OnTriggerExit(other);

        HapticMaterial mat = other.GetComponent <HapticMaterial>();

        if (mat != null)
        {
            touchingMaterials.Remove(mat);
            HapticHandler.DoPulseData(node, mat.GetEndTouchPulse(body.velocity));
        }
    }
    public override void Release(Interactable interactable)
    {
        base.Release(interactable);

        HapticMaterial mat = interactable.GetComponent <HapticMaterial>();

        if (mat != null)
        {
            HapticHandler.DoPulseData(node, mat.GetBeginTouchPulse(body.velocity));
            mat.onCollisionNode = XRNode.LeftEye;
        }
    }
Пример #4
0
    private void OnCollisionExit(Collision collision)
    {
        if (onCollisionNode != XRNode.LeftEye)
        {
            HapticPulseData dat = material.GetEndHitPulse(collision.relativeVelocity.magnitude);

            if (dat.amplitude1 > 0f || dat.amplitude2 > 0f)
            {
                HapticHandler.DoPulseData(onCollisionNode, dat);
            }
        }
    }
    public override void Hold(Interactable interactable)
    {
        base.Hold(interactable);

        HapticMaterial mat = interactable.GetComponent <HapticMaterial>();

        if (mat != null)
        {
            HapticHandler.DoPulseData(node, mat.GetBeginTouchPulse(body.velocity));
            mat.SetStartHoldPos();
            mat.onCollisionNode = node;
        }
    }
    protected void SetCurrentAngle(float angle)
    {
        if (rotationRange > 0f)
        {
            if (angle > rotationRange)
            {
                angle = rotationRange;
            }
            else if (angle < 0f)
            {
                angle = 0f;
            }

            UnityEngine.XR.XRNode node;
            if (held && holder.GetNode(out node) && angle != currentAngle)
            {
                if (angle == 0f)
                {
                    HapticHandler.DoPulseData(node, onMinReachedPulse);
                }
                else if (angle == rotationRange)
                {
                    HapticHandler.DoPulseData(node, onMaxReachedPulse);
                }
                else if (currentAngle == 0f)
                {
                    HapticHandler.DoPulseData(node, onMinLeftPulse);
                }
                else if (currentAngle == rotationRange)
                {
                    HapticHandler.DoPulseData(node, onMaxLeftPulse);
                }
            }
        }

        currentAngle = angle;

        Quaternion rotMod = Quaternion.AngleAxis(angle - initialRotation, alignmentAxis);

        transform.rotation = rotMod * originalRot;
        transform.position = hingePoint.TransformPoint(rotMod * originalDir * hingeDist);
    }