Example #1
0
        protected override void OrientEnemyToTarget(float delta, Vector2 targetPosition)
        {
            Vector2 currentPosition = GetGlobalPosition();

            _targetRotation = -Mathf.Rad2Deg(Mathf.Atan2(
                                                 currentPosition.x - targetPosition.x,
                                                 currentPosition.y - targetPosition.y
                                                 )) - 90;


            float currentRotation = ExtensionFunctions.LerpAngleDeg(_rotationNode.GetGlobalRotationDegrees(), _targetRotation, rotationRate * delta);

            _rotationNode.SetGlobalRotationDegrees(currentRotation);
        }