예제 #1
0
        public override void UpdateController()
        {
            if (enabled)
            {
                tracking = true;

                if (leftFootAnimation == null)
                {
                    leftFootAnimation = ivr.leftFootTarget.GetComponent <IVR_Animate>();
                }
                if (rightFootAnimation == null)
                {
                    rightFootAnimation = ivr.rightFootTarget.GetComponent <IVR_Animate>();
                }

                if (selected)
                {
                    if (legMovements)
                    {
                        FeetAnimation();
                    }
                    else if (followHip)
                    {
                        FollowHip();
                    }
                }
            }
            else
            {
                tracking = false;
            }
        }
예제 #2
0
        private void FootStepping(IVR_Animate footAnimation, Vector3 startHipFoot)
        {
            if (footAnimation.f >= 1)
            {
                footAnimation.startStep = false;
                footAnimation.f         = 0;
            }
            else if (footAnimation.f > 0)
            {
                stepStart = new Vector3(stepStart.x, ivr.transform.position.y, stepStart.z);
                Vector3 stepTarget = ivr.hipTarget.TransformPoint(startHipFoot) - stepStart;
                stepTarget = new Vector3(stepTarget.x, startPosition.y, stepTarget.z);

                if (curSpeed.x != 0 || curSpeed.z != 0)
                {
                    Vector3 avgSpeed2 = basePointDelta / footAnimation.f;
                    stepTarget += avgSpeed2 / 2;
                }

                Vector3 newPosition = footAnimation.AnimationLerp(Vector3.zero, stepTarget, ref footAnimation.f);

                transform.position = stepStart + newPosition;
                transform.rotation = ivr.hipTarget.rotation; // should be eased towards this rotation in the end
                lastPos            = transform.position;
            }
        }
예제 #3
0
        public override void StartController(InstantVR ivr)
        {
            extension = ivr.GetComponent <IVR_Animator>();
            base.StartController(ivr);

            startHipFootL = ivr.hipTarget.InverseTransformPoint(ivr.leftFootTarget.position);
            startHipFootR = ivr.hipTarget.InverseTransformPoint(ivr.rightFootTarget.position);

            if (transform == ivr.leftFootTarget)
            {
                isLeftFoot         = true;
                leftFoot           = this;
                rightFoot          = ivr.rightFootTarget.GetComponent <IVR_AnimatorFoot>();
                leftFootAnimation  = gameObject.AddComponent <IVR_Animate>();
                lastPos            = transform.position;
                startHipFoot       = startHipFootL;
                localStartPosition = ivr.transform.InverseTransformPoint(ivr.leftFootTarget.position);
            }
            else
            {
                rightFoot          = this;
                leftFoot           = ivr.leftFootTarget.GetComponent <IVR_AnimatorFoot>();
                rightFootAnimation = gameObject.AddComponent <IVR_Animate>();
                lastPos            = transform.position;
                startHipFoot       = startHipFootR;
                localStartPosition = ivr.transform.InverseTransformPoint(ivr.rightFootTarget.position);
            }

            startFootLposition = ivr.leftFootTarget.position - transform.position;
            startFootRposition = ivr.rightFootTarget.position - transform.position;

            lastHipPosition = ivr.hipTarget.position;
        }
예제 #4
0
        protected void FootStepRight(IVR_Animate footAnimation, Vector3 hipTargetPosition, Vector3 footTargetPosition, bool follow)
        {
            if (footAnimation.startStep == false)
            {
                basePointStart          = ivr.transform.position;
                stepStart               = new Vector3(footTargetPosition.x, ivr.transform.position.y, footTargetPosition.z);
                footAnimation.startStep = true;

                if (!follow)
                {
                    rightFoot.lastStepRight = true;
                }
                leftFoot.lastStepLeft = false;
            }
        }