Why is OnTriggerEnter not working properly?
Hi,
My goal is to create a simple multiplayer FPS. Sofar I've created a simple room in space where 2 robots will combat by trying to shoot eachother (the room has a meshcollider). I've also created some cargo-crates with box-colliders. Both the room and the crates are non moving objects. Next I created the bullet with a rigidbody. The bullet is instantiated on shooting and is been given a velocity. The bullet itself has a script with an OnTriggerEnter onboard. When the bullet collides, a very simple particle explosion is called and the bullet is destroyed.
Shooting on the cargo works fine: everytime I hit a crate there is a nice burst of sparkles, just what I want. But when the bullet hits a wall of the room, most of the time the bullet just goes through the wall, not triggering the OnTriggerEnter on the bullet. I also putted a Debug.Log in the onTriggerEnter, but it isn't called.
On the image below you can see that sometimes I have the effect I want (left). If I keep shooting at the same spot it's good. But when I just move a lttle or I want to shoot just next to the same place on the wall, the bullet is going through the wall: definitly not what I want...
I searched the forum, noticed more problems with the OnTriggerEnter, but in all cases not the problem I'm facing. First I thought I was only hitting the wireframe of the mesh, but that isn't the case. Any ideas why the OnTriggerEnter could not be working properly?
Answer by Herman1981 · Jan 05, 2018 at 01:14 PM
Is it the meshcollider which isn't reliable as the box- en capsulecolider? Cause those colliders seem to work fine...