Add FootstepGfx and JumpGfxComponent; implement particle effects for footsteps and jumps

This commit is contained in:
2025-09-13 05:19:37 +02:00
parent dfc9201f62
commit db2a090acc
15 changed files with 488 additions and 3 deletions

View File

@@ -0,0 +1,35 @@
using Godot;
namespace Mr.BrickAdventures.scripts.components;
[GlobalClass]
public partial class JumpGfxComponent : Node2D
{
[Export] public PackedScene ParticleScene { get; set; }
[Export] public PlayerController Controller { get; set; }
public override void _Ready()
{
if (Controller == null)
{
GD.PrintErr("JumpGfxComponent must have a reference to a PlayerController.");
SetProcess(false);
return;
}
Controller.JumpInitiated += OnJumpInitiated;
}
private void OnJumpInitiated()
{
SpawnGfx();
}
private void SpawnGfx()
{
var particleInstance = ParticleScene.Instantiate<GpuParticles2D>();
particleInstance.GlobalPosition = GlobalPosition;
GetTree().CurrentScene.AddChild(particleInstance);
particleInstance.Emitting = true;
}
}