Search Unity

Question Teleporting an Interpolating Rigidbody

Discussion in 'Physics' started by Igotlazy, Dec 4, 2023.

  1. Igotlazy


    Jan 15, 2018
    From what I understand, you shouldn't directly set the transform.position of an interpolating rigidbody, since the interpolation is handling transform movement for the sake of reducing visual jitter.

    In that case, how should I go about teleporting an interpolating rigidbody? Setting transform.positon seems to cause "fighting" as the interpolation will try to yank the object back to where the physics system thinks the object should be.

    Setting rigidbody.position seems to do the trick, as it doesn't take interpolation into account. The actual transform doesn't get updated immediately though, which might be a pain for other scripts trying to figure out the position of the object.

    Currently I am setting rigidbody.position and then transform.position, and all seems to be working. Is there some unintended side effects with this? What is standard practice?
  2. Edy


    Jun 3, 2010
    It looks correct to me, and I can't think on any unwanted effect on doing that. Indeed, most likely that is the correct way of dealing with this situation (teleporting a Rigidbody with interpolation enabled and ensuring the updated position is available to others right after the change).
    POOKSHANK likes this.