Move objects in Update and check collision immediately

Hello.

Execution Order of Event Functions says event functions executed in this order.

  • FixedUpdate(Physics)
  • Input
  • Update
  • Rendering

In Update(), I move objects(with collider + kinematic rigidbody) by Input result.

If a moved object collide another object, I want destroy them in that Update().

But OnTriggerXXX or OnCollisionXXX are not triggered until FixedUpdate executed in next frame.

So, even objects collide, they are destroyed in next frame, not the frame they collides.

I want to destroy collide objects in the frame they collides.

Is there any way?

You should move your objects in FixedUpdate() if they have rigidbody’s and you are moving them via physics(AddForce). If you are moving physic’s objects(rigidbody’s) via any other method then that is not advised. You should have your trigger events wait for the Fixed Update. But ultimately if you are using physics then you are not going to be doing things in relation to frame rate, except for player input which is always frame dependent and as such should always be handled in Update().