NetworkedObject Ownership Management
See original GitHub issueDescription: The ownership lifecycle seems to have a gap in it. We have an object whose ownership we would like to pass from player to player. The ownership transfer is initiated by each individual player when specific conditions are met.
MLAPI prevents non-server clients from requesting ownership transfer. This throws an error when called on clients:
public void ChangeOwner(ulong ownerID) {
this.NetworkedObject.ChangeOwnership(ownerID);
}
NotServerException: Only the server can change ownership
MLAPI.Spawning.SpawnManager.ChangeOwnership (MLAPI.NetworkedObject netObject, System.UInt64 clientId) (at C:/projects/mlapi/MLAPI/Spawning/SpawnManager.cs:207)
Additionally, setting up a server-side ownership transfer method also throws error (because I’m guessing the ulong ownerID argument is being confused with the ulong method hash and wires are getting crossed):
public void ChangeOwner(ulong ownerID) {
InvokeServerRpc(this.ServerRPCOwnerChange, ownerID);
}
[ServerRPC]
public void ServerRPCOwnerChange(ulong ownerID) {
this.NetworkedObject.ChangeOwnership(ownerID);
}
NullReferenceException: Object reference not set to an instance of an object
MLAPI.NetworkedBehaviour.InvokeServerRPCLocal (System.UInt64 hash, System.UInt64 senderClientId, System.IO.Stream stream) (at C:/projects/mlapi/MLAPI/Core/NetworkedBehaviour.cs:708)
MLAPI.NetworkedBehaviour.SendServerRPCPerformance (System.UInt64 hash, System.IO.Stream messageStream, System.String channel, MLAPI.Security.SecuritySendFlags security) (at C:/projects/mlapi/MLAPI/Core/NetworkedBehaviour.cs:843)
MLAPI.NetworkedBehaviour.SendServerRPCBoxed (System.UInt64 hash, System.String channel, MLAPI.Security.SecuritySendFlags security, System.Object[] parameters) (at C:/projects/mlapi/MLAPI/Core/NetworkedBehaviour.cs:739)
MLAPI.NetworkedBehaviour.InvokeServerRpc[T1] (MLAPI.NetworkedBehaviour+RpcMethod`1[T1] method, T1 t1, System.String channel, MLAPI.Security.SecuritySendFlags security) (at C:/projects/mlapi/MLAPI/Core/RPCMethods/NetworkedBehaviour.BoxedServerRpc.cs:32)
Expected Behavior: Hoping that it’s within the scope of your intended ownership control that we can pass ownership between players and player/server somewhat willy nilly.
Environment:
- OS: Windows 10
- Unity Version: 2018.4.9f1
- MLAPI Version: 11.2.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
NetworkObject | Unity Multiplayer Networking
Player NetworkObjects. Player objects are an optional feature in Netcode you can use to assign a networked object to a specific client. A...
Read more >Controlling ownership of objects and disabling ACLs for ...
Control ownership of new objects that are uploaded to your Amazon S3 bucket and disable access control lists (ACLs) for your bucket using...
Read more >Configuring Object Ownership in Networked Photon ...
In this tutorial, you'll learn to assign and transfer ownership to GameObjects in Photon-enabled applications. This is useful because it allows a user...
Read more >Ownership - Fish-Net: Networking Evolved
When a client owns an object they are considered the rightful user to take actions on the object, such as moving a character...
Read more >Ownership, Unity Multiplayer with Fish-Networking - YouTube
Asset Store: https://assetstore.unity.com/packages/tools/ network /fish-net- networking -evolved-207815 Github: ...
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
Yes, thank you for your support via Discord. I added a bunch more logging and found that I was adding a NetworkedObject at runtime and the order in which I was doing that was screwing up everything. The problem was 100% on my side and MLAPI is amazing. 😃 Thanks!
Has this been solved?