mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 08:55:55 +00:00
Strafing and crosshair for FSM player
This commit is contained in:
parent
5073cfea70
commit
af0261ce8e
6 changed files with 170 additions and 23 deletions
32
Scripts/Components/Actors/PlayerCrosshairProvider.cs
Normal file
32
Scripts/Components/Actors/PlayerCrosshairProvider.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.Actors;
|
||||
|
||||
public partial class PlayerCrosshairProvider : Node2D
|
||||
{
|
||||
[Export]
|
||||
public AnimatedSprite2D AnimatedSprite { get; private set; }
|
||||
|
||||
[Export]
|
||||
public float CrosshairDistance { get; private set; }
|
||||
|
||||
public void UpdatePosition(Vector2 facingDirection)
|
||||
{
|
||||
AnimatedSprite.Position = CalculateCrosshairPosition(facingDirection);
|
||||
}
|
||||
|
||||
private Vector2 CalculateCrosshairPosition(Vector2 facingDirection)
|
||||
{
|
||||
return facingDirection * CrosshairDistance;
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
AnimatedSprite.Show();
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
AnimatedSprite.Hide();
|
||||
}
|
||||
}
|
||||
1
Scripts/Components/Actors/PlayerCrosshairProvider.cs.uid
Normal file
1
Scripts/Components/Actors/PlayerCrosshairProvider.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d208gvthkstvc
|
||||
35
Scripts/Components/Actors/PlayerHitboxSpriteProvider.cs
Normal file
35
Scripts/Components/Actors/PlayerHitboxSpriteProvider.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.Actors;
|
||||
|
||||
public partial class PlayerHitboxSpriteProvider : Node2D
|
||||
{
|
||||
[Export]
|
||||
public AnimatedSprite2D Hitbox { get; private set; }
|
||||
[Export]
|
||||
public AnimatedSprite2D Circle { get; private set; }
|
||||
|
||||
public void SetVisibility(bool isVisible)
|
||||
{
|
||||
if (isVisible)
|
||||
{
|
||||
Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
Hitbox.Show();
|
||||
Circle.Show();
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
Hitbox.Hide();
|
||||
Circle.Hide();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://3jxrxcqp3ndr
|
||||
Loading…
Add table
Add a link
Reference in a new issue