MiniGames/Assets/ChaseRunZibuSquisher.cs
2025-09-11 18:46:20 +05:00

32 lines
917 B
C#

using UnityEngine;
public class ChaseRunZibuSquisher : MonoBehaviour
{
[Header("Squish Settings")]
[Tooltip("How long the Y-scale takes to reach 0.")]
public float squashTime = 0.25f;
[Tooltip("Delay after squish before Game Over.")]
public float postSquishDelay = 0.35f;
[Tooltip("Optional: if set, this transform is squished instead of the root.")]
public Transform squashTargetOverride;
private bool triggered;
private void OnTriggerEnter(Collider other)
{
if (triggered) return;
if (!other.CompareTag("Player")) return;
// Get the controller from the player or its parents
var controller = other.GetComponentInParent<ChasePlayerController>();
if (controller == null) return;
triggered = true;
// Fire the squish kill
controller.KillBySquish(squashTargetOverride, squashTime, postSquishDelay);
}
}