• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ROMgame · Sep 20, 2015 at 07:22 PM · collisionphysicsrigidbodyphysics2dexecution order

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:

  1. 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.

  2. Following the "FixedUpdate()", "OnCollisionEnter()" is automatically called - telling the object that it has entered the left wall - as expected.

  3. "Update()" is automatically called on all objects.

  4. "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!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vivek-Joshi · Sep 22, 2015 at 06:28 AM 0
Share

Try reducing it's velocity, if it helps.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Recalculating collisions after Physics2D.IgnoreLayerCollision()? 1 Answer

Is it possible to disable collisions for separate physics scene? 0 Answers

Velocity data from OnCollisionEnter is delayed (incorrect) 2 Answers

Rigidbody wall slide without velocity loss 2 Answers

Influence of the collision on the other object 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges