using System.Collections; using System.Collections.Generic; using UnityEngine; public class FallingRocks : MonoBehaviour { Rigidbody rb; public float speed; [SerializeField] private DeathZone _dz; private void Start() { rb = GetComponent(); } // Use OnTrigger to make the "rocks" fall to the ground. Rate of fall can be controlled with speed variable. private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { rb.velocity = Vector3.down * speed; } } // Use OnCollison to call respawn method from DeathZone script. private void OnCollisionEnter(Collision collision) { if (collision.gameObject.TryGetComponent(out PlayerDeath playerDeath)) { playerDeath.Respawn(); } } }