Teleporting Rigidbodies

I couldn’t find any helpful articles about this, so I’m hoping to help the next person struggling with this.

I ran into a situation where I was pooling missiles in Cleared Hot, and occasionally when a unit would shoot them, they would originate from a different location. A few would come from where they were supposed to, then a few would come from like 50 meters to the left, and some would come from way off in the distance, presumably at 0,0,0.

I was doing all the standard precautions for moving rigidbodies:

  • Using Rigidbody.position
  • Setting it to kinematic
  • Turning interpolation off

However the last thing I was doing was adding a force to launch the missile.

The only thing that seemed to fix it was to retrieve the pooled prefab, and then queue up the addForce call until the next FixedUpdate.

Perhaps there’s some issue with teleporting a rigidbody and adding force to it at a time other than a FixedUpdate interval.

So if you’re seeing your rigidbodies appearing all over the place, here’s your lifeline. Get them from the pool whenever, and then wait for FixedUpdate to use them.