Beispiel #1
0
        private void UpdateRotation()
        {
            var currentPosition      = ship.GetPosition();
            var lookAtTargetPosition = LookAt.GetPosition(currentPosition);

            var lookAtDelta     = lookAtTargetPosition - currentPosition;
            var targetRotation  = lookAtDelta.GetAngle();
            var currentRotation = ship.Rigidbody2D.rotation;

            ship.Rigidbody2D.rotation = Mathf.MoveTowardsAngle(currentRotation, targetRotation, 100 * Time.fixedDeltaTime);
        }