Hi, I have this script :
private int slideBank;
void Awake () {
slideBank = 0;
}
void Update() {
Debug.Log(slideBank);
}
void OnCollisionEnter(Collision hit) {
if (hit.transform.CompareTag ("Slide")) {
{
Debug.Log("IN");
slideBank++;
}
}
}
void OnCollisionExit(Collision hit) {
if (hit.transform.CompareTag ("Slide")) {
{
Debug.Log("OUT");
slideBank--;
}
}
}
So the problem is, when my player (which is own this script), and another object that have “Slide” tag colliding, my console only showing “IN” once and without “OUT”.
But inside the Update debug, it shown
1 0 1 0 1 0 1 0 1 0 1 0 1 0
while the object still collide.
Notice that we have zero in there while I only decreased the value if “OUT” is shown.
Do you have any idea why does it happen?
Or maybe there’s something about OnCollissionEnter / Exit that I missed.
Thanks.