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

25 lines
858 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 _collider;
[Export] private ShapeCast2D _shapeCast2D;
[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)
{
Vector2 newPos = new Vector2(direction.X * _xOffset, direction.Y * _yOffset);
_collider.Position = newPos;
_shapeCast2D.TargetPosition = newPos;
}
}