Esempio n. 1
0
        void StepRotation()
        {
            rotationAxis = VectorMath.GetAxisDirection(rb.transform, alignAxis);
            cross        = Vector3.Cross(rotationAxis, referenceAxis);
            deltaAngle   = Vector3.Angle(rotationAxis, referenceAxis);

            rb.AddTorque(deltaAngle * force * cross, forceMode);
            rb.AddTorque(-rb.angularVelocity * damper, forceMode);
        }
Esempio n. 2
0
        void SetReferenceAxis()
        {
            if (!target)
            {
                return;
            }

            switch (followStyle)
            {
            case FollowStyle.MatchTarget: referenceAxis = VectorMath.GetAxisDirection(target, alignAxis); break;

            case FollowStyle.AimAtTarget: referenceAxis = (target.position - rb.position).normalized; break;

            case FollowStyle.None: break;
            }
        }