- Home /
addforce causing object to teleport.
I have gameobjects using rigidbody interacting with each other, and applying an acceleration using rigidbody.AddForce(accel, ForceMode.Acceleration). This works fine using objects I put in the scene before running it, but when I instantiate them in game, there is a problem.
I pause the interactions by setting bool RunScene = false, and save the velocity of each object to a temporary vector then set the velocity to zero. Upon resuming the velocity is reset to the correct value and it all works fine.
When the game is paused I can instantiate more objects into the scene, alter their velocity (to be) and position them. However upon resuming they will teleport to a new location, before interacting normally. I've isolated the problem to be the AddForce function, disabling it will cause the objects to be fine, but as soon as I apply a force it instantly moves somewhere else. Further pausing and unpausing work as they should.
So my question is, is there any effects of rigidbody or instantiation that could be making this a problem? Attempts to force the object to be at the right position aren't working. Even adding a zero acceleration has the same effect.
Your answer
Follow this Question
Related Questions
How to make a ball capable of rolling around a loop the loop? 1 Answer
Rigidbody-based spaceship? 1 Answer
Jumping with rigid body3d 1 Answer
rolling ball movement on different axis 0 Answers