- Home /
Collision Detection not Firing
Hi all,
I know this is a common question, but I haven't found the answer that resolves the problem I have.
Basically I making a 3D game wheere I have a trigger cube as a child to the camera from the standard FPSController prefab which detects objects it collides with. I have a dummy object for testing in the scene. Both the trigger and the objects have debugging scripts attached which track the object(s) they collide with/trigger. Both objects have colliders.
Testing script:
public class CheckCollided : MonoBehaviour
{
void OnTriggerEnter(Collider other)
{
print (gameObject.name + " triggered by " + other.gameObject.name);
}
void OnCollisionEnter(Collision other)
{
print (gameObject.name + " collided by " + other.gameObject.name);
}
}
The problem is both functions aren't firing.
I've tried all these options but none of them work.
Made either and both objects a trigger.
Attached kinematic rigidbodies to either and both objects.
But the collision is still not getting detected.
Any reasons as to why they aren't working?
Only the object that you are colliding with needs to be set as a trigger. The collider on your camera should be set as a collider (don't check isTrigger). Also, it's best to put the RigidBody on your player.