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.
25 lines
862 B
25 lines
862 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 RaycastDetector _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)
|
|
{
|
|
Vector2 newPos = new Vector2(direction.X * _xOffset, direction.Y * _yOffset);
|
|
_collider.GlobalPosition = newPos;
|
|
_detector.TargetPosition = newPos;
|
|
}
|
|
} |