#NetworkBehaviour spawning and despawning...

1 messages ยท Page 1 of 1 (latest)

ancient harness
#

Which makes sense why the other example Sets the intial state in OnNetworkSpawn with a "server/Authority/Owner" check

strange belfry
#

A lot of people are too used to the Awake Start Update paradigm. Networking is a different ball game and your code (IMO) should revolve around when you have received and synchronized data

plain forge
#

Network Variables would not be updated until OnNetworkSpawn() so reading them beforehand would not be correct. They need to be registered with the network manager on the server side before being written to and that happens on spawn as well

ancient harness
#

Wait sorry. I need to do more reading now. Thank you for the help though

ancient harness
#

#archived-networking message @strange belfry

Here you said to check HasAuthority, but my Unity is saying.
error CS0103: The name 'HasAuthority' does not exist in the current context
I am not sure if it is a version thing. Here is how it is being used.

        public override void OnNetworkSpawn()
        {
            if (HasAuthority)
            {
                _networkPosition.Value = Data.Position;
                _networkRotation.Value = Quaternion.Euler(Data.Rotation);
                _networkScale.Value = Data.Scale;
                _networkColor.Value = Data.Color;
                _networkIsSolarSystem.Value = Data.IsSolarSystem;
            }
            
            // TODO Not sure if owner should subscribe, or maybe ignore the event in the handler of it changed?
            // Sync local state for any network changes
            _networkPosition.OnValueChanged += Handle_NetworkPosition_OnValueChanged;
            _networkRotation.OnValueChanged += Handle_NetworkRotation_OnValueChanged;
            _networkScale.OnValueChanged += Handle_NetworkScale_OnValueChanged;
            _networkIsSolarSystem.OnValueChanged += Handle_NetworkIsSolarSystem_ValueChanged;
            _networkColor.OnValueChanged += Handle_NetworkColor_OnValueChanged;
        }

Should I use that differently, or would IsOwner work here instead?

strange belfry
plain forge
#

You need to be in Unity 6 and using NGO2 to use Distributed Authority

ancient harness
plain forge
ancient harness
#

Okay. I remember some docs on handling late joiners, but their search is failing me.

plain forge
#

There shouldn't be anything special you have to regarding spawning or ownership with late joiners.

ancient harness
# strange belfry The client.

Probably because the funkiness of my setup. But the Server is the default owner on a NetworkObject.Spawn(), had to do a NetworkObject.SpawnWithOwnership()

strange belfry
#

Default ownership for client-server will always be the server.

ancient harness
#

Is host migration still not supported out of the box with Relay?

strange belfry
ancient harness
#

Ah, that is really bad ๐Ÿ˜…

#

In the sense of for me, but also as a design by Unity, though not suprising Unity would make something that bad.

#

Huge lag spike when the host disconects. Also looking at other issues, like the time for the host being disconnected is big.

strange belfry
ancient harness
#

Photon

strange belfry
#

They allow you to switch the "Master Client". That's not Host Migration. Nowhere close.

ancient harness
#

๐Ÿคท๐Ÿปโ€โ™‚๏ธ

strange belfry
ancient harness
#

Interesting

ancient harness
#

Okay so I was thinking that I would have to respawn the entire scene, but when the host leaves, and I assign a new host, will all the NetworkObjects in the room still be(not including if their state changed after host disconnect) in a valid state? Or at least still have the same network ID? So I just need to get a new Relay?

#

Outside of tons of complications of course for my custom implementation

plain forge
#

in client server when the host leaves the entire network gets shut down. all network objects get destroyed.
With distributed authority, if the object was to set to distributable authority, then they will get transferred to the remaining clients