Question by
KidCanada7 · Dec 10, 2021 at 11:47 PM ·
collisiongameobject
OnCollisionEnter not running all Fields.
I'm trying to make it so when my character touches an Obstacle my Levels it pops up with a Death UI, but it's not setting the UI active. All the other fields work in the first if statement except the Gameobject one. How do I fix this? using UnityEngine; public class PlayerCollision : MonoBehaviour { public Movement movement; public GameObject deathUI; void OnCollisionEnter (UnityEngine.Collision collisionInfo) { if (collisionInfo.collider.tag == "Obstacle") { deathUI.SetActive(true); movement.enabled = false; FindObjectOfType<GameManager>().EndGame(); } if (collisionInfo.collider.tag == "JumpPad") { GetComponent<Rigidbody>().AddForce(Vector3.up * 500); } } }
Comment