Removed a coin bug

This commit is contained in:
MarcUs7 2024-12-29 16:23:26 +01:00
parent a1a563a7fa
commit aa6085b151
2 changed files with 9 additions and 2 deletions

View file

@ -25,8 +25,8 @@ public class SC_2DCoin : MonoBehaviour
_canPickUp = false; // Disable picking up coins temporarily _canPickUp = false; // Disable picking up coins temporarily
TotalCoins++; TotalCoins++;
c2d.GetComponent<PlayerMovement>().PlayCoinSound(); PlayerMovement.ShouldPlayCoinSound = true;
Destroy(gameObject); Destroy(gameObject);
// Start the cooldown coroutine // Start the cooldown coroutine

View file

@ -24,6 +24,7 @@ public class PlayerMovement : MonoBehaviour
private static readonly int IsCrouching = Animator.StringToHash("IsCrouching"); private static readonly int IsCrouching = Animator.StringToHash("IsCrouching");
public static InputActions InputActions; public static InputActions InputActions;
public static bool ShouldPlayCoinSound;
private void Awake() private void Awake()
{ {
@ -95,6 +96,12 @@ public class PlayerMovement : MonoBehaviour
{ {
animator.SetBool(IsJumping, true); animator.SetBool(IsJumping, true);
} }
if (ShouldPlayCoinSound)
{
ShouldPlayCoinSound = false;
PlayCoinSound();
}
} }
public void OnLanding() public void OnLanding()