My game is not recognizing collisions with my player. If I use OnCollisionEnter with my player nothing happens, but if I use OnTriggerEnter things happen as it seems they should. What’s going on with that? I have been using OnTriggerEnter as a workaround but that is not always practical and I would like to understand what the issue is here…
Is the collider set to be a trigger maybe?
The purpose of that is that collision will be ignored and trigger messages will be sent.
Is the collider set to be a trigger maybe?
Actually, no, though I have added a raycast collider set to trigger to try to deal with using OnTrigger instead. But before adding that I was working with the Character Controller and I also tried it with a capsule collider added.
The Character Controller does in itself act like a collider though, doesn’t it?
Hi. I’ve been working on this problem (after trying to just get around it) and I made a new project to isolate the issue. I made a large box for the player to walk on, added a First Person Controller from the Unity Prefabs, and then added a standard cube and named it “Box”. I put this code on the First Person Controller:
function OnCollisionEnter (object) {
if (object.transform.name == "Box") {
print ("Hit Box!");
}
}
When I play the “game” the FPC stops when it runs into the box but the print line does not print. Is it the code here that’s wrong? Or am I messing something else up? It seems like this should be easy…
Try attaching a kinematic rigidbody to the collider.
I tried, but had no results. This is weird and has brought my game to a standstill. Is the above code the wrong code to be using for checking player collisions? The test file I am using (as described above) is really simple so there can’t be too many other places I might be screwing things up…