Hello everyone,
I am working on a project and have been hung up on collisions for almost two hours now. I’ve read through countless articles and my code matches those I’ve read yet I see no results.
In my project I have a mouse that moves towards a block of cheese. My goal is when he mouse collides with the cheese for it to remove 10 health from the cheese and remove the mouse. I added debug logs and the script isn’t even firing.
This is on the cheese gameObject:
private void OnCollisionEnter(Collision collision){
if (collision.gameObject.name == "mouse"){
Debug.Log("[CHEESE] - Collision Detected");
currentHealth -= 10;
}
}
This is on the mouse gameObject:
private void OnCollisionEnter(Collision collision){
if (collision.gameObject.name == "cheese"){
Destroy(collision.gameObject);
Debug.Log("[MOUSE] - Collision Detected");
}
}
Both gameObjects have a rigid body and a box collider. Collision Detection is “Continuous”.
mouse Component Settings:
IsTrigger: True
IsKinematic: False
cheese Component Settings:
IsTrigger: True
IsKinematic: False
Thanks a lot in advance for all help given. ![]()
-Joshua4missions