- Home /
check when a projectile that is a trigger hits a mesh that is also a trigger
void OnTriggerEnter(Collider current)
{
print("here"); // never gets here.
if (current.tag == "Projectile")
{
obj.health -= 10;
}
}
I want to check when a projectile that is a trigger hits a mesh that is also a trigger. The code above does nothing. It never actually gets inside the OnTriggerEnter.
Please help
Answer by Ashkan_gc · Jan 22, 2012 at 11:08 AM
One of them should have a kinematic rigidbody attached, you can check the isKinematic checkbox on the rigidbody to make it kinematic. so do these steps
Attach a Rigidbody component to your projectile prefab.
check the isKinematic checkbox on the rigidbody
run the game now
Kinematic rigidbodies don't act like normal ones so you can move the gameObject like before and it's still a normal triger and can not be moved by forces.
take a look at link textphysics manual pages for more information about the collision matrix and messages being sent between different colliders and kinematic rigidbodies.
maybe it's moving too fast. enable continous collision dtection in rigidbody that is kinematic and doulbe check if is trigger is checked in both of them.
Yes Trigger is checked in both. I tried moving it at different speeds and it did not help. Continous collision failed as well. :(