2025-02-28 17:46:02 -05:00
|
|
|
using System.Collections;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class FallPlatform : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public float fallDelay = 2f;
|
2025-03-03 19:03:34 -05:00
|
|
|
public float resetDelay = 2f;
|
2025-02-28 17:46:02 -05:00
|
|
|
|
|
|
|
|
bool falling;
|
|
|
|
|
Rigidbody2D rb;
|
2025-03-05 21:08:52 -05:00
|
|
|
//Transform defposition;
|
2025-02-28 17:46:02 -05:00
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2025-03-05 21:08:52 -05:00
|
|
|
//defposition = gameObject.transform;
|
2025-03-03 11:58:00 -05:00
|
|
|
rb = transform.parent.GetComponent<Rigidbody2D>();
|
2025-03-03 19:03:34 -05:00
|
|
|
|
2025-02-28 17:46:02 -05:00
|
|
|
}
|
2025-03-03 11:58:00 -05:00
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
2025-02-28 17:46:02 -05:00
|
|
|
{
|
2025-03-03 13:44:31 -05:00
|
|
|
if (!falling/* && collision.gameObject.CompareTag("Player")*/)
|
2025-02-28 17:46:02 -05:00
|
|
|
{
|
|
|
|
|
StartCoroutine(FallAfterDelay());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerator FallAfterDelay()
|
|
|
|
|
{
|
|
|
|
|
falling = true;
|
|
|
|
|
yield return new WaitForSeconds(fallDelay);
|
|
|
|
|
rb.bodyType = RigidbodyType2D.Dynamic;
|
2025-03-05 21:08:52 -05:00
|
|
|
yield return new WaitForSeconds(resetDelay);
|
|
|
|
|
//Respawn();
|
2025-02-28 17:46:02 -05:00
|
|
|
}
|
2025-03-05 21:08:52 -05:00
|
|
|
|
|
|
|
|
//private void Respawn()
|
|
|
|
|
//{
|
|
|
|
|
//rb.bodyType = RigidbodyType2D.Static;
|
|
|
|
|
//gameObject.transform.position = defposition.position;
|
|
|
|
|
//}
|
2025-02-28 17:46:02 -05:00
|
|
|
}
|