#Execution Order - Syncing Avatar Rig to Network Transform (VR Player).

6 messages · Page 1 of 1 (latest)

keen cloak
#

Hello! I have a VR game where I am syncing head and hand transforms via Fish-Net's NetworkTransform. I also have a secondary player avatar rig (not parented to the NetworkTransform) which I am updating every frame to match the position/rotation of the corresponding NetworkTransform.

Currently, I update the position of the player avatar to match the NetworkTransform position/rotation in the 'Update' loop. However, I am wondering if this is the correct thing to do. I am worried about a one-frame delay in position updates or race condition where my avatar position/rotation sometimes gets updated before NetworkTransform updates its position/rotation. Do I need to go into the Unity settings to adjust the execution order of my avatar script to update positions later in the execution order (so that NetworkTransform can update the position before my avatar rig updates its position)? Or possibly even move the avatar position update into 'LateUpdate'?

I tried looking at NetworkTransform's code to look for clues but became a little lost. When in the execution order of my update loop should I update an (unparented) avatar rig's position/rotation to match the NetworkTransforms for my VR player's head and hands so that there is no frame delay or race condition?

keen cloak
#

I guess a simpler question that would help me know what to do is: Exactly when in the execution order does NetworkTransform update its transform's position/rotation each frame?

robust flame
#

To the best of my knowledge it is updated in Unity's Update method

keen cloak
#

So if I want to update a transform (such as an unparented VR avatar hand) to exactly match the NetworkTransform's position/rotation each frame, I should do that in Update? But I would need to go into Project Settings > Script Execution Order, add my script, and give it a positive number so it always executes after NetworkTransform and not before?

Could you please confirm, @inland shell? Thank you!

robust flame
#

I think it would be easier to use LateUpdate

keen cloak
#

Normally yes, but in my specific case I am doing an operation in LateUpdate to sync up the avatar colliders with the physics system (I call Physics.SyncTransforms() in LateUpdate). So, I would need my avatar position/rotation to be synced up before that occurs.

So, this combination of factors is why I want to pinpoint exactly when NetworkTransform does its thing, and when to do my things. 🙂