hello,
how can i get the position of an object right before collision. lets say that we have one sphere static and another moving toward the the static and they collide. how am i to get the position of the moving object right before they collided and trajectories changed.
1 Like
Store the Rigidbody(2D) pose in the FixedUpdate callback. By default, simulation is run after all the FixedUpdate callbacks have been made.
1 Like
hi, thanks for your reply…
could you please elaborate a little. i do not know what you mean by store the Rigidbody pose… is pose position?
also can i store rigidbody(3d)?
how would this look like?
I use the term pose to mean Rigidbody position and rotation.
So in short, on a GameObject where you need to know what the position/rotation were before the simulation, add a FixedUpdate call and store both in a pair of private fields in your script.
After FixedUpdate is called on all scripts, the simulation is run or you can manually run it yourself after all FixedUpdate callbacks have run. This means you have a script or scripts where the previous simulation position/rotation are stored to do whatever you like with.
2 Likes