- Home /
OnCollisionEnter only detects once
This code works as it detects collision between a cube a floor and a Wall. The problem is the cube I drop (like this video), is that I only detect the collsiion once with the wall and floor, even though the cube bounces around many times on the floor. Why is this?
http://www.unity3dstudent.com/2010/07/beginner-b01-basic-collision-detection/
void OnCollisionEnter(Collision collision) {
if (collision.gameObject.name=="Floor")
{
Debug.Log("Hit Floor");
}
if (collision.gameObject.name=="Wall")
{
Debug.Log("Hit wall");
}
}
Answer by Berenger · Jun 04, 2012 at 01:02 AM
For the collision to be detected again, the cube must leave the floor completely. If it just slide, then it doesn't enter again. Make sure the cube bounces high enough.
Yes it does bouce high enough , it just doesnt register in the console but if I look at the Editor log and see the S$$anonymous$$S trace I get multiple detections here.
Why is this happening as it works fine in S$$anonymous$$S trace but not in console?
aaarrggghh I had collapse selected and not clear on play. my mistake again.
Answer by jagguy · Jun 04, 2012 at 03:17 AM
aaarrggghh I had collapse selected and not clear on play. my mistake again.
Your answer
