- Home /
Trigger no longer registering scenery
I'm at my wits end here. I have a player collider which suddenly refuses to detect the scenery in my level.
It was working fine only yesterday. I made a few changes to meshes and object orientation and now it doesn't work. No changes were made to collision matrix or layers.
OnTriggerEnter simply fails to detect the scenery all of a sudden. The maddening thing is, the collider will detect pickups, but not scenery. The only way it will detect scenery is if I replace the scenery mesh collider with a box collider - not very useful.
Does anyone know why my mesh colliders could suddenly have stopped working?
Answer by Bunny83 · Jun 09, 2011 at 12:57 PM
Ok, some points:
The whole collision/trigger-system is part of the physics system.
Collisions or trigger messages can only be generated by non-kinematic rigidbodies when they are awake.
If a non-kinematic RB don't move for a while (1-2 sec) it fall asleep.
If the RB is moved, or hit by another rigidbody it wakes up.
kinematic rigidbodies can wake up other non-kinematic rigidbodies in order to have the physics calculated.
If you move a normal collider ( without rigidbody ) into a sleeping rigidbody no collisions are detected.
Normal(non-convex) MeshColliders can not collide with other MeshColliders.
Only convex MeshColliders can collide with other non-convex MeshColliders.
Since you always need a non kinematic rigidbody you should add this one to the moving object. A Rigidbody represents a moving physics object.
Player characters normally are build with primitive colliders. In most cases (like the charactercontroller) it's just a capsule.
If it worked before you may had the collider turned into a convex collider.
It worked before because I was using a dummy object for the player with a capsule collider. When I put the spaceship model in I replaced the capsule with a mesh collider. I left collisions off for a few days so I could test other stuff and when I turned them back on I'd forgotten about replacing the collider.
I've got it working now with a box collider on the player ship. As the mesh is simple I tried using the mesh collider with convex set on but it still wouldn't detect the scenery... hmmmm
Answer by Anxo · Jun 09, 2011 at 11:30 AM
No, but here are some pointers to remember.
Its most of the time better to build box colliders to mimic your scene than it is to use mesh colliders. Meshcolliders are very heavy and may have a negative effect on your game's proformance.
Make sure your collider is not inside of another collider, that your collider does not have an ignore physics in the code, that if you have a rigidbody attached to the player, that is is not kinetic, colliders only work with a none kinetic rigidbody.
If all that does not work, I would try to retrace your steps and undo the changes you did to see what the problem was as well as re-importing the mesh.
I hope that helps.
Answer by Recluse · Jun 09, 2011 at 12:20 PM
Thanks,
I'm using mesh colliders as it's not practical to mimic my scenery with box colliders - the game uses virtually no physics so no worries on performance - runs at constant 40fps.
My player collider is set as a Trigger and I am testing for other objects colliding using OnTriggerEnter.
I simply want to know if the player object bumped into another object - I don't need any physics at all. Do triggers detect if a mesh collider has entered the trigger?
I've double-checked the collision matrix.
I've reimported the meshes and the changes I made really shouldn't have affected collision detection - I simply rotated the original meshes in Blender then reimported them as well as changing from a 1st person viewpoint to a 3rd person viewpoint.
It's odd. A few days ago it was all working fine... I am stumped.
I thought something might be wrong with the scenery meshes but the player's bullets are registering the scenery and bouncing off it!
Yet the Player ship will not register scenery unless I replace the colliders with a box collider.
Now why is that????
Answer by Recluse · Jun 09, 2011 at 12:48 PM
Solved it... replaced Ship Mesh collider with Sphere (which I originally used) and it works again.
Mesh Colliders cannot collide with each other.
Your answer
Follow this Question
Related Questions
how do i correctly use a box collider 1 Answer
how do i correctly use a box collider 0 Answers
Have part of mesh change color 0 Answers
Collision Checking 1 Answer
OnTriggerEnter not recognising collision ?(Solved) 3 Answers