How to correctly set up Network Transform/Network Rigidbody?
I'm sorry, this is probably a very basic question, but I don't seem to be able to figure it out on my own.
What do I have to do in order to correctly set up a Network Rigidbody?
I have a very basic scene with a Network Runner. The game is set to launch in shared mode automatically.
I have one object with a Rigidbody, a Network Object and a Network Rigidbody components.
When I start two instances of the game, one of them is able to move the object and that change is copied just fine on the other instance. But when I try to invert the roles, it doesn't work. If I grab the object in the second instance, it doesn't move in the first one and the instant I drop it, it goes back to its original position.
Also, the method TeleportToPosition isn't doing anything.
What am I doing wrong?
Thanks for your help
Best Answer
-
Are you changing the StateAuthority for the object to the other player? Only the StateAuthority of the object can modify its position. If a player which does not have StateAuthority moves it, then those changes will be quickly overwritten by incoming states from the actual authority.
A player can take over authority with: Object.RequestStateAuthority();
Whoever, either the previous authority must first call Object.ReleaseStateAuthority(), or the NetworkObject must have AllowStateAuthorityOverride enabled.
1
Answers
-
Are you changing the StateAuthority for the object to the other player? Only the StateAuthority of the object can modify its position. If a player which does not have StateAuthority moves it, then those changes will be quickly overwritten by incoming states from the actual authority.
A player can take over authority with: Object.RequestStateAuthority();
Whoever, either the previous authority must first call Object.ReleaseStateAuthority(), or the NetworkObject must have AllowStateAuthorityOverride enabled.
1