Search Unity

Moving rigidbodies with MovePosition/MoveRotation outside of FixedUpdate

Discussion in 'Scripting' started by PrimeDerektive, Jul 26, 2012.

  1. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    I'm working on an authoritative networking scenario inspired by Valve's multiplayer networking papers, specifically the part about collecting snapshots of collider positions/rotations and rewinding them at the moment of calculating a fired shot to it's position in time equal to Network.time - transitTime - clientViewInterpolation.

    I have it working fine and dandy, but moving colliders around just based on transforms with colliders and no rigidbodies is a very expensive process, due to collision data needing to be recalculated. To that end, I changed all my "hitbox" collider objects to be kinematic rigidbodies, and am doing the rewind with MovePosition/MoveRotation... it performs much better, but it happens exactly when the RewindHitBoxes() function is called, which needs to happen in the exact frame that the shot is being simulated, right before the raycast.

    It's been working great, I just feel like I'm doing something dirty, not operating within FixedUpdate, but I can't afford to wait for the next physics step. Is there any unforeseen consequences of what I'm doing that I might run into?

    cross-post: http://answers.unity3d.com/questions/291070/moving-rigidbodies-with-movepositionmoverotation-o.html
     
    Last edited: Jul 26, 2012