Added Footsteps SFX
This commit is contained in:
@@ -5,8 +5,8 @@ namespace Babushka.scripts.CSharp.Common.Animation;
|
||||
public partial class Duck : Node2D
|
||||
{
|
||||
[Export] private CharacterBody2D _characterBody;
|
||||
[Export] private AudioPlayer _nakNakAudio;
|
||||
[Export] private AudioPlayer _wingFlapAudio;
|
||||
[Export] private AudioPlayer2D _nakNakAudio;
|
||||
[Export] private AudioPlayer2D _wingFlapAudio;
|
||||
[Export] private Node2D _vesna;
|
||||
[Export] private float _runningSpeed = 3f;
|
||||
[Export] private float _slowSpeed = 0.5f;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Audio;
|
||||
|
||||
public partial class AudioPlayer : AudioStreamPlayer
|
||||
{
|
||||
/// <summary>
|
||||
/// For SFX and other audio that should be played only once and not looped.
|
||||
/// </summary>
|
||||
public void PlayOneShot()
|
||||
{
|
||||
Play();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dx25g14a7xi4w
|
||||
@@ -2,7 +2,7 @@ using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common;
|
||||
|
||||
public partial class AudioPlayer : AudioStreamPlayer2D
|
||||
public partial class AudioPlayer2D : AudioStreamPlayer2D
|
||||
{
|
||||
/// <summary>
|
||||
/// For SFX and other audio that should be played only once and not looped.
|
||||
@@ -1,4 +1,3 @@
|
||||
using Babushka.scripts.CSharp.Common.Inventory;
|
||||
using Babushka.scripts.CSharp.Common.Services;
|
||||
using Godot;
|
||||
|
||||
@@ -7,8 +6,7 @@ namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
||||
public partial class PlayerMovement : CharacterBody2D
|
||||
{
|
||||
[Export] private float _speed = 1000f;
|
||||
|
||||
private InventoryManager _inventoryManager;
|
||||
[Export] private Timer _stepTimer;
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
@@ -48,6 +46,21 @@ public partial class PlayerMovement : CharacterBody2D
|
||||
|
||||
anyActionPressed = true;
|
||||
}
|
||||
|
||||
if (Velocity.LengthSquared() == 0 && currentVelocity.LengthSquared() > 0)
|
||||
{
|
||||
_stepTimer.Start();
|
||||
_stepTimer.SetPaused(false);
|
||||
GD.Print("Start");
|
||||
}
|
||||
|
||||
if (currentVelocity.LengthSquared() == 0 && Velocity.LengthSquared() != 0)
|
||||
{
|
||||
_stepTimer.Stop();
|
||||
_stepTimer.SetPaused(true);
|
||||
GD.Print("Stop");
|
||||
}
|
||||
|
||||
|
||||
if (anyActionPressed)
|
||||
{
|
||||
@@ -66,5 +79,9 @@ public partial class PlayerMovement : CharacterBody2D
|
||||
Velocity = currentVelocity;
|
||||
MoveAndSlide();
|
||||
}
|
||||
else
|
||||
{
|
||||
Velocity = Vector2.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user