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
+7 -2
View File
@@ -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
+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");
+9 -7
View File
@@ -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) {