- Home /
Question by
unity_uYmRyWZxVlsMeg · Jan 02, 2021 at 07:59 PM ·
collision issues
Have problem with OnCollisionExit
I tried to remove the image when the player no longer colliding with the object by using oncollisionexit but didnt work. Hope somebody can show me where is my mistake.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI;
public class Questionctrl : MonoBehaviour { public GameObject Questions; public float delay;
private void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "Player")
{
Time.timeScale = 0f;
delay = 5f;
Questions.SetActive(true);
Destroy(this.gameObject);
}
}
private void OnCollisionExit(Collision other)
{
if (other.gameObject.tag == "Player")
{
Questions.SetActive(false);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Box pushes another box while it's supposed to move on top of it 0 Answers
Multiplayer: Rigidbodies, character controllers or something else?! 1 Answer
OnTriggerEnter() not working on faster speeds 0 Answers
Best way to implement an advanced collision system? 1 Answer
collisions will sometimes be detected and sometimes will not 1 Answer