예제 #1
0
        private void RotateBody()
        {
            Vector3 targetDirection  = new Vector3(m_Direction.x, 0, m_Direction.y);
            float   maxRotationAngle = Vector3.Angle(m_Body.transform.forward, targetDirection);

            if (maxRotationAngle > m_RotationReachAngle)
            {
                Quaternion rotation = RotationUtility.Rotate(m_Body.transform.forward, targetDirection, Vector3.up
                                                             , m_RotationSpeed * Time.fixedDeltaTime);
                Quaternion newRotation = m_Body.rotation * rotation;
                m_Body.MoveRotation(newRotation);
            }
        }
예제 #2
0
        private void Update()
        {
            Vector3 forward = new Vector3(m_TargetDirection.x, 0, m_TargetDirection.y);

            if (m_InstantRotate)
            {
                m_Turret.rotation = Quaternion.LookRotation(forward, Vector3.up);
            }
            else
            {
                Quaternion rotation = RotationUtility.Rotate(m_Turret.forward, forward, Vector3.up, m_RotationSpeed * Time.deltaTime);
                m_Turret.rotation *= rotation;
            }
        }
예제 #3
0
 /// <summary>
 /// Rotates the object, so it SHOULD turn toward the position.
 /// </summary>
 public void TurnTo(Vector2 turnposition)
 {
     Rotation.Set(RotationUtility.TurnTowards(Position, turnposition));
 }