- Home /
Unity Physics Collision Execution Order Error?
So in my game I have two wall objects, "Left Wall" and "Right Wall". They are separated by a large empty room.
I then have an object attached to the right wall, when I tap the mouse button the idea is that a large force will be applied to the object on the right wall to fling it onto the left wall in a single frame. The problem is - the following happens:
The mouse button is pressed and the object that is attached to the right wall has its velocity modified during the next frames "FixedUpdate()" - increasing it to a very, very high value.
Following the "FixedUpdate()", "OnCollisionEnter()" is automatically called - telling the object that it has entered the left wall - as expected.
"Update()" is automatically called on all objects.
"OnCollisionExit()" is automatically called - telling the object that it has exited the right wall
So that's pretty weird - the object should be told it has exited the right wall at the same time it's told that it has entered the left wall (before Update) - right? They definitely are not overlapping - i've separated them by huge amounts of space to be sure. So why isn't OnCollisionExit being called right after FixedUpdate? Very puzzling!
Note : My actual use case is not the above - the above is just a simplified version I've been testing to help me to debug why OnCollisionExit isn't getting called straight after FixedUpdate!
Any help would be much appreciated - I'm at a bit of a loss for how to solve this one!
Answer by dudester · Sep 22, 2015 at 01:43 PM
perhaps your frame rate is to high or your timestep is to low , if its the first try enable vsync as Update is called each frame reduces the framerate to 60 and try increase your Timestep also make sure to mark your rigidbody as continuous dynamic so as to ensure its doing the collision right,also unless your wall is very thin its gonna take a lil time for the wall to exit the collider so maybe one frame?
Your answer
Follow this Question
Related Questions
Recalculating collisions after Physics2D.IgnoreLayerCollision()? 1 Answer
Is it possible to disable collisions for separate physics scene? 0 Answers
Handling colliders on hundreds of asteroids (not procedural asteroids) ...URGENT 3 Answers
physics culling mask? 1 Answer
Keep Horizontal Momentum after Jump 2 Answers