Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Impossible to move non player local authoritative objects #273
Describe the bug
As you can see in the code above, there is an if statement which will check if connectionToServer != null, but if this is a non-player local authoritative object for which you have the authority, then this statement will fail and no updates will be sent to the server.
In the previous version of the NetworkTransform, as well as in the UNET itself, ClientScene.readyConnection was used for the very same check, therefore changing it as well as the send call in the if statement, will fix this problem, however, not sure if this affects anything else.
The non-player local authoritative objects don't even move on the client side, and this is the line of code that is causing it.
In this case:
(isLocalPlayer && hasAuthority) == false
Therefore, this object will be teleported or interpolated back to the old position if you try to move it.
FIX (Disclaimer: Same as before, not sure how this affects LAN Hosts (server & client) because I'm not using it, therefore it needs to be tested.)
Hope didn't forget to mention anything, thanks for reading.
Well, in my case I have vehicles which can be controlled by players. Server spawns the vehicles, and if any of the players wishes to control one of the vehicles they must send a request to the server so the server can assign the authority. This way only one player at a time can control any of the vehicles.
I too am having this issue. I created a project to demonstrate it.
Build and run external instance. Host on external instance. Connect client inside unity editor. Press Q on the host to pass the black cube authority to the client. Move the client in the editor and you'll see on the host that it doesn't update the cube's location.
The above example demonstrates the issue, but my use case isn't represented with it. Mine would be for VR when a player would pick up an object. The player client has to be able to take over the authority of an object in order for other players to see him carry it around so to speak.
I made the following changes to NetworkTransformBase in the same location Ed had posted above. This may not be an adequate fix, but it got my VR app back on track.
I didn't know UNET can do that.