Files
Crash-Course/Assets/Scripts/FallPlatform.cs

36 lines
810 B
C#
Raw Normal View History

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;
bool falling;
Rigidbody2D rb;
2025-03-03 19:03:34 -05:00
//Vector3 position;
void Start()
{
rb = transform.parent.GetComponent<Rigidbody2D>();
2025-03-03 19:03:34 -05:00
//position = rb.transform.position;
}
private void OnTriggerEnter2D(Collider2D collision)
{
2025-03-03 13:44:31 -05:00
if (!falling/* && collision.gameObject.CompareTag("Player")*/)
{
StartCoroutine(FallAfterDelay());
}
}
private IEnumerator FallAfterDelay()
{
falling = true;
yield return new WaitForSeconds(fallDelay);
rb.bodyType = RigidbodyType2D.Dynamic;
2025-03-03 19:03:34 -05:00
//yield return new WaitForSeconds(resetDelay);
}
}