From 42cf65f331bd4fed12d60a6a26c8de1617de7158 Mon Sep 17 00:00:00 2001 From: go38coz Date: Sat, 6 Jun 2026 20:04:15 +0200 Subject: [PATCH] fallingAnimationThreshold introtuced; moved activation to damageHandler --- Game/Assets/Scenes/0_MainScene.unity | 9 +++++++-- Game/Assets/Scripts/DamageHandler.cs | 20 +++++++++++++++----- Game/Assets/Scripts/DropletMovement.cs | 16 +++++++++------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/Game/Assets/Scenes/0_MainScene.unity b/Game/Assets/Scenes/0_MainScene.unity index ba0e5b3..4f65c5d 100644 --- a/Game/Assets/Scenes/0_MainScene.unity +++ b/Game/Assets/Scenes/0_MainScene.unity @@ -3097,12 +3097,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2b3b9fc97a2d39d2d84c4be43a79247a, type: 3} m_Name: m_EditorClassIdentifier: Assembly-CSharp::DamageHandler - threshold: 2.5 - multiplier: 0.5 + threshold: 15 + multiplier: 0.1 maxHealth: 1 health: 0 minSize: 0.4 maxFallingTime: 2 + fallingAnimTreshold: 0.2 --- !u!1001 &703703567 PrefabInstance: m_ObjectHideFlags: 0 @@ -5971,6 +5972,10 @@ PrefabInstance: propertyPath: jumpingPower value: 9 objectReference: {fileID: 0} + - target: {fileID: -8535381027169538, guid: d56297e435f8410a584581d73d99d2e4, type: 3} + propertyPath: fallingAnimationVelocityThreshold + value: 5 + objectReference: {fileID: 0} - target: {fileID: 2141180002423843430, guid: d56297e435f8410a584581d73d99d2e4, type: 3} propertyPath: m_Name value: PlayerDroplet diff --git a/Game/Assets/Scripts/DamageHandler.cs b/Game/Assets/Scripts/DamageHandler.cs index 23cb7c1..1719554 100644 --- a/Game/Assets/Scripts/DamageHandler.cs +++ b/Game/Assets/Scripts/DamageHandler.cs @@ -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(); + animator = GetComponent(); } 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"); diff --git a/Game/Assets/Scripts/DropletMovement.cs b/Game/Assets/Scripts/DropletMovement.cs index 11ebce3..c3f679f 100644 --- a/Game/Assets/Scripts/DropletMovement.cs +++ b/Game/Assets/Scripts/DropletMovement.cs @@ -30,6 +30,8 @@ public class DropletMovement : MonoBehaviour [SerializeField] private TrailRenderer tr; [SerializeField] private Animator animator; + [SerializeField] private float fallingAnimationVelocityThreshold = 3f; + void Start() { @@ -64,13 +66,13 @@ public class DropletMovement : MonoBehaviour //Jump animation - if (rb.linearVelocityY < -3f && !isGrounded) - { - animator.SetBool("Falling", true); - } else - { - animator.SetBool("Falling", false); - } + // if (rb.linearVelocityY < fallingAnimationVelocityThreshold && !isGrounded) + // { + // animator.SetBool("Falling", true); + // } else + // { + // animator.SetBool("Falling", false); + // } //Walk animation if (movement.x > 0) {