FishNet icon indicating copy to clipboard operation
FishNet copied to clipboard

How's transform syncing for VR games?

Open emrys90 opened this issue 3 years ago • 5 comments

A unique system that Normcore networking has, that I have not been able to find in any other assets, is ownership of the object is different than ownership of position. When a physics object collides with another object its position owner changes, which allows near seamless physics for a multiplayer virtual reality game.

Here's an article that covers how to do VR physics networking well, and they have the concept of a different position owner as well. https://gafferongames.com/post/networked_physics_in_virtual_reality/

emrys90 avatar Jun 05 '22 03:06 emrys90

Do you mean make it so multiple clients can control an objects position?

FirstGearGames avatar Jun 05 '22 21:06 FirstGearGames

Only one client controls it at a time, but a client requests control of the object and immediately can start changing its position without having to wait for a response from the server. Control of position is different than control of SyncVar values of the object itself.

The article explains in detail how to accomplish syncing of physics objects for VR.

emrys90 avatar Jun 05 '22 21:06 emrys90

I guess you can change the item's ownership (with client prediction, then you can roll back the state when other players actually grab it before you) once you grab it and move it with client authoritative.

I implement this in MLAPI, but I am also very interested if FishNet has some built-in features to support this.

AnomyxStudio avatar Jun 07 '22 06:06 AnomyxStudio

Only one client controls it at a time, but a client requests control of the object and immediately can start changing its position without having to wait for a response from the server. Control of position is different than control of SyncVar values of the object itself.

The article explains in detail how to accomplish syncing of physics objects for VR.

I understand what you are saying and I can 100% see a use for this. I'll make sure it makes it onto the roadmap. Keeping issue open until I get it up there.

FirstGearGames avatar Jun 15 '22 00:06 FirstGearGames

Thank you!

emrys90 avatar Jun 15 '22 02:06 emrys90

I know this has been opened awhile. I wanted to implement this sooner but things got re-arranged. I'll make sure this is happening within the next release or two.

FirstGearGames avatar Oct 29 '22 17:10 FirstGearGames

Great, thank you!

emrys90 avatar Oct 30 '22 03:10 emrys90

Great, thank you!

I just got this feature complete and I realized, wouldn't it make more sense if immediate ownership of the entire object was faked instead of just the NetworkTransform. That way all IsOwner checks would pass rather than only granting you access to control the NT.

FirstGearGames avatar Nov 06 '22 21:11 FirstGearGames

No, because you don't necessarily want the owner of the object to change. For example, a player summons an object, and that object should disappear when that player disconnects. But other players are allowed to move it through physics. Physics ownership should not be the same as object ownership.

emrys90 avatar Nov 06 '22 23:11 emrys90

You cannot really control an object without ownership. The NetworkTransform changes were just faking ownership until it transferred over on the NetworkObject. Now it's essentially the same but all scripts will receive the ownership change.

FirstGearGames avatar Nov 07 '22 00:11 FirstGearGames

I see. Unfortunately, that won't be a good solution for networking VR physics then.

[EDIT] Not only because of the ownership issue, but because of the synchronization too. The article explains the data transfer has to go both ways, not just local simulation. A client requests transform ownership and takes over it as if its client authoritative, with syncing data to the server, that the server then syncs to other clients. This process starts happening immediately on the client with no delay waiting for ownership transfer from the server to complete. But its also in combination with decoupling object ownership from transform ownership that fully completes it.

emrys90 avatar Nov 07 '22 00:11 emrys90

I'm not sure this is as much a problem as you believe. I did assume you were using a NetworkTransform, but I imagine this would behave the proper way for anything. If you were say using a PredictedObject you would still get ownership of it allowing you to control it however you want.

FirstGearGames avatar Nov 07 '22 00:11 FirstGearGames

I'll have to use a different system then, but thanks for looking into it. Ownership shouldn't be the same as movement control for VR physics. If you want to learn more on the subject, I would recommend looking into the Normcore networking asset in Unity. They have the best multiplayer networking physics for VR that I've tried. I just don't use their asset because its peer to peer only.

emrys90 avatar Nov 07 '22 00:11 emrys90

I'm not sure I understand entirely. Ownership doesn't necessarily mean the object is now client auth it just means the client has the right to communicate with the server on it. Another day please get to me on Discord so we can discuss because I feel as though this would work.

FirstGearGames avatar Nov 08 '22 02:11 FirstGearGames

You can read up on Normcore's documentation for how they handle syncing transforms to learn why it's different. One of the key parts is when an owned transform collides with an unowned transform, it requests ownership of it, so it can immediately start syncing positions of all collided objects to other clients.

There might be better ways to handle it, I'm not sure, but its the best multiplayer physics I've seen in VR. Other options just haven't worked as well for realtime physics syncing with hands colliding with objects from multiple players.

And all of that is done without changing who the original owner of the object is. https://normcore.io/documentation/realtime/realtimetransform.html

emrys90 avatar Nov 08 '22 03:11 emrys90