using System.Collections; using System.Collections.Generic; using UnityEngine; public class ChildBallBehaviour : MonoBehaviour { [SerializeField] private Rigidbody _ball; [SerializeField] private float speed = 100f; [SerializeField] private GameObject _ballEventTrigger; void Start() { } // Update is called once per frame void Update() { } public void BallMovement() { } public void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { _ball.AddForce((-Vector3.forward * speed), ForceMode.Force); Debug.Log("I did it"); } } public void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Player") { WaitForBallDisappearance(); _ball.gameObject.SetActive(false); _ballEventTrigger.SetActive(false); Debug.Log("I did it"); } } public IEnumerator WaitForBallDisappearance() { yield return new WaitForSeconds(5.0f); } }