You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Babushka/scripts/CSharp/Common/CharacterControls/DetectionCross.cs

22 lines
732 B

using Godot;
namespace Babushka.scripts.CSharp.Common.CharacterControls;
/// <summary>
/// Moves the Detector to the position in accordance with the player view to limit the player's range of actions to the ones in front of them.
/// </summary>
public partial class DetectionCross : Node2D
{
[Export] private Detector _detector;
[Export] private float _xOffset;
[Export] private float _yOffset;
/// <summary>
/// Gets the current look direction of the player and moves the detection shape with it.
/// </summary>
/// <param name="direction"></param>
public void SetDirection(Vector2 direction)
{
_detector.Position = new Vector2(direction.X * _xOffset, direction.Y * _yOffset);
}
}