IsLocalPlayer should check on NetworkObjectId instead of OwnerClientId
See original GitHub issueDescribe the bug
When you remove the ownership of an NetworkObject
. IsLocalPlayer
is not true for the localPlayer but NetworkManager.Singleton.LocalClientId
is still the same as before.
To Reproduce
Create NetworkObject
and let the server remove ownership
Actual outcome
The IsLocalPlayer
is not true on local player anymore.
Expected outcome The IsLocalPlayer should still be true on local player.
Environment (please complete the following information):
- MLAPI V0.1.0
Additional context
In this line OwnerClientId
should be NetworkObjectId
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Question - Problem Spawning Objects, help!
for the server to spawn it. The way it's done in the tutorial is by checking whether the PlayerObject is (IsLocalPlayer) , and...
Read more >Manual: Network Identity
This allows you to inspect the information which can be useful for investigation and debugging. The scene ID is valid in all scene...
Read more >On netcode while running as a host does the hosting client ...
To decide if the local client is the owner of a NetworkObject, you can check the NetworkBehaviour.IsOwner property. To decide if the server...
Read more >COMPLETE Unity Multiplayer Tutorial (Netcode for ... - YouTube
I'm your Code Monkey and here you will learn everything about Game ... Then you can add whatever Network Object to it and...
Read more >Problem with Spawning at runtime and ...
Hi, I try to implement a jenga tower. So, I have introduced a JengaBlock prefab. I have added the Networked Object, the Tracked...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @MFatihMAR,
i hope this clarifies what i wanted to say.
This is correct.
When i call
NetworkObject.RemoveOwnership
to give the server ownership theNetworkManager.LocalClientId
remains the same. This is not suprising because since i just changed the ownership its still the same id for the local client. The Problem is when i now callNetworkObject.IsLocalPlayer
on my client it returns false which should not be right because the client is still my local Player and not the server.Before i remove the ownership the
NetworkObject.IsLocalPlayer
is true on the client (becauseOwnerClientId
equalsNetworkManager.LocalClientId
), but when i call the RPC the client loses itsNetworkObject.IsLocalPlayer
because it is not longer the owner of theNetworkObject
. So now i can’t write code that does something on clientside when iam the localplayer.In my opintion the
NetworkObject.IsLocalPlayer
check has nothing to do withOwnerClientId
because it doesn’t matter who is the owner at the moment it is always that one client who started the connection, that is the local player (else you could also just change theNetworkManager.LocalClientId
to something else)I hope you can now understand why i want to change the check, if not please let me know.
@Dockyardb I am just running through the remaining open issues and wanted to try and help clarify some things as well as provide you with additional updates to server authoritative NetworkTransform.
NetworkObject.IsLocalPlayer denotes that the NetworkObject in question represents the client’s “local player”. If you remove the ownership of the NetworkObject (which is what represents the local player) then the client will still have a connection but no assigned player NetworkObject.
NetworkTransform has been updated (quite a bit in v1.0.2) where ownership no longer determines authority. So a server authoritative NetworkTransform (the default) now means it is “true server authoritative” which means:
If you run into any additional issues with this please feel free to post here and I would be happy to assist you further.