Hitbox visible

This commit is contained in:
Marco 2025-01-28 10:43:35 +01:00
commit 0ccc272ada
10 changed files with 141 additions and 17 deletions

View file

@ -44,6 +44,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
private GameManager _gameManager;
[Export] public Sprite2D HitboxSprite { get; set; }
private bool _isStrafing { get; set; }
[Signal]
@ -192,10 +194,30 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
}
// public override void _Draw()
// {
// if (_isStrafing)
// {
// HitboxSprite.Visible = true;
// }
// else
// {
// HitboxSprite.Visible = false;
// }
// base._Draw();
// }
public override void _PhysicsProcess(double delta)
{
_movementDirection = GetInput();
_isStrafing = Input.IsActionPressed("strafe");
// Toggle visibility of the hitbox sprite based on strafing
if (HitboxSprite != null)
{
HitboxSprite.Visible = _isStrafing;
}
_rightStickInput = GetRightStickInput();
// Update Facing Direction