32 lines
667 B
C#
32 lines
667 B
C#
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(Rigidbody))]
|
|
public class Skywalker_DroppingPlatform : MonoBehaviour
|
|
{
|
|
[Header("Platform Settings")]
|
|
public float dropDelay = 1f;
|
|
|
|
private Rigidbody rb;
|
|
private bool triggered = false;
|
|
|
|
void Start()
|
|
{
|
|
rb = GetComponent<Rigidbody>();
|
|
rb.isKinematic = true; // start frozen
|
|
}
|
|
|
|
void OnCollisionEnter(Collision col)
|
|
{
|
|
if (!triggered && col.collider.CompareTag("Player"))
|
|
{
|
|
triggered = true;
|
|
Invoke(nameof(Drop), dropDelay);
|
|
}
|
|
}
|
|
|
|
void Drop()
|
|
{
|
|
rb.isKinematic = false; // platform falls with physics
|
|
}
|
|
}
|