-
Notifications
You must be signed in to change notification settings - Fork 446
IsOwner false on a NetworkBehaviour with 'NetworkObject that has IsOwner = True' #3210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What NetworkTopology are you using (Client-Server or Distributed Authority)? Could you post the code showing how you're instantiating the NetworkObject and the NetworkBehaviour? |
Thank you for the code snippet. Do you mind explaining more about what behaviour you were expecting vs what was happening? |
I am spawning the FIGHTER object with SpawnWithOwnership so I am expecting all the NetworkBehaviours attached on that FIGHTER object to also have isOwner = true for owners. But as it turns out, only the NetworkObject component has isOwner = true for owner clients, and not the network behaviours. I am currently working around this by using reference of the NetworkObject and checking NetworkObj.IsOwner. |
Hi @MaybeKush, There might be some additional script I will need to better help you, but before we do that I have some recommendations based on the script segment you provided us:
Once you have made those adjustments, let me know if you are still getting the same result. |
@NoelStephensUnity Is that specific to netcode ? Because with pure Unity, instantiating a gameobject, or one of its root component, will still instantiate the whole gameobject. Only the reference returned by the Instantiate method will change (gameobject vs the root component) |
@NoelStephensUnity could you please confirm or deny the above info ? |
@NoelStephensUnity Sorry for the late reply, must have missed the notification email.
This is a common instantiating method, if we want to use a specific component on an instantiated object, we can directly spawn the component of that type, instead of spawning gameobject then fetching the component on it. But I'll still try if spawning a gameobject makes any difference.
This, I can get behind. I'll try and return with the results Passing |
This was my mistake and I am not really sure why I added that comment other than I was thinking about "new" as opposed to Instantiate which creates a new instance of the GameObject and its components itself. >.<
This should help with things a bit. |
@MaybeKush Until the issue has been resolved, you have two primary options: Player Prefab Spawning (Client-Server)
Below is a project providing you with both examples of how to do this: When you open the project, you should first open the BootStrapScene and look at the The
NetworkManager Player PrefabThis option would follow the same flow you have been using with the exception that a client's child object is spawned upon the client finishing being synchronized. The script of interest here is the Client Connected Callback and Client Connected EventBoth of these options override the Why Is This Required (for the player spawning)Currently (for connecting clients), this is the logical flow for NetworkManager defined player prefab spawning:
Either case, I am marking this issue as a bug because I believe we can change the order of operations to:
However, until we get this fix in place you will need to use one of the other techniques I provided in the above attached example project. Thank you for your patience on this issue. |
@MaybeKush @kevincastejon This same fix will be in v1.13.0 via the #3388 backport (this should be soon but I can't give an exact date of when this package will be available). |
Description
I have a class Fighter inheriting from NetworkBehaviour. Then a more specific class for the Fighter innheriting from Fighter. That class is attached to an object with NetworkObject component attached. I start server, spawn the object on Server (dynamically) with ownership = client (btw I spawn this new NetworkObject by Instantiating it under our Player default object, which is spawned by Network Manager under the Default Player Prefab field. Then after Instantiating it under that, only 1 line after I spawn it on the Network using its NetworkObject through the server). NetworkObject says IsOwner true, NetworkBehaviour script says IsOwner = false.
Reproduce Steps
Idk the steps exclusively. Though it could be related to Inheriting or how I instantiated it.
Actual Outcome
IsOwner is false on NetworkBehaviour but true on NetworkObject.
Expected Outcome
IsOwner should have been true in both NetworkObject and all NetworkBehaviours attached to it.
Screenshots
Console is logging IsOwner from the NetworkBehaviour script
Environment
The text was updated successfully, but these errors were encountered: