fallingAnimationThreshold introtuced; moved activation to damageHandler

This commit is contained in:
go38coz
2026-06-06 20:04:15 +02:00
parent c3a795090d
commit 42cf65f331
3 changed files with 31 additions and 14 deletions
+15 -5
View File
@@ -6,6 +6,7 @@ using UnityEngine.SceneManagement;
public class DamageHandler : MonoBehaviour
{
private Rigidbody2D rb;
private Animator animator;
public float threshold = 2.5f;
public float multiplier = 0.5f;
@@ -17,20 +18,17 @@ public class DamageHandler : MonoBehaviour
private bool falling;
private float fallTime;
public float maxFallingTime = 2f;
public float fallingAnimTreshold = 0.5f;
private void Awake()
{
rb = GetComponent<Rigidbody2D>();
animator = GetComponent<Animator>();
}
private void Start()
{
threshold = 10f;
multiplier = 0.1f;
maxHealth = 1f;
minSize = 0.8f;
health = maxHealth;
}
@@ -58,6 +56,18 @@ public class DamageHandler : MonoBehaviour
lastYVelocity = currentVelocity;
}
private void Update()
{
if (falling && fallTime >= fallingAnimTreshold)
{
animator.SetBool("Falling",true);
}
else
{
animator.SetBool("Falling",false);
}
}
private void OnCollisionEnter2D(Collision2D other)
{
// Debug.LogWarning("collide");