#rpc not properly working

1 messages ยท Page 1 of 1 (latest)

crimson tartan
#

i am now, and it seems nothing has changed, the gameobject that is on the scene newly loaded to does correctly spawn on the network though and go to ddol, but the object in the previous scene before switching scenes doesn't seem to spawn as a network scene in time before the scene switches ?

#

when the client connects the server will be on a different scene so it loads a new scene basically as soon as it connects

#

or whenever the client is updated to change scenes in unity that is

subtle tide
#

Are you still seeing that object in DDOL, on the client?

crimson tartan
#

the networkmanager, and the object that is in the scene it loads too (but not in the scene it came from) are both in ddol on the client when it changes scenes, but the object in the first scene doesn't follow it into the new scene, as if the scene switches before the network object spawns and it gets put into ddol?

#

the game starts on scene 0 with a worldmanager, host moves to scene 1 and brings worldmanager with it, and scene 1 has a ddol playerspawner
client starts, moves to scene 1 because the host is, but the worldmanager doesn't get networkspawned and put on ddol before the scene switches (scene 1 doesn't have world manager), but the player spawner correctly spawns and moves to ddol (which isn't in scene 0 but is in scene 1)

#

sorry if im describing this poorly

#

worldmanager never shows in ddol because as soon as the client starts which is when worldmanager would spawn as a networkobject and get put to ddol, the scene changes (seemingly before the networkobject worldmanager spawns, and it's put into ddol)

subtle tide
#

as long as worldmanager is spawned on the host, it will get spawned on the client whenever they join

crimson tartan
#

how do i make sure it spawns on the host

#

i just have the default settings of network object

#

the object exists on the host when it loads the scene but not on the client when it loads the scene

subtle tide
crimson tartan
#

the debuglog logs on the server but not the client

subtle tide
#

could be a bug. try removing base.OnNetworkSpawn();

crimson tartan
#

it's clearly connected to the server enough to know to change the scene

subtle tide
#

Its not a singleton is it? I've seen network object singletons destroy themselves on spawn

crimson tartan
#

when i start a client, it gets added as an observer into the host

crimson tartan
#

so it's showing the client as an observer to the object, but not spawning the object on that client

subtle tide
#

weird. not sure how that is possible. open a bug report on that

crimson tartan
#

so.. how do i get this working ๐Ÿ˜ญ

subtle tide
#

I would remove the DDOL() for now

crimson tartan
crimson tartan
# crimson tartan

the client id has no prefab as i set that in code and instantiate it as a player at runtime

#
public void SpawnPlayer()
{
    if(pc == null)
    {
        Debug.Log(playerPrefab);
        pc = Instantiate(playerPrefab, transform.position, Quaternion.identity);
        pc.GetComponent<NetworkObject>().SpawnAsPlayerObject(NetworkManager.LocalClientId);
    }

    pc.transform.position = transform.position;
}```
#

i've got this but it does the same thing

public override void OnNetworkSpawn()
{
    base.OnNetworkSpawn();

if(IsServer)
    DontDestroyOnLoad(this);

    Debug.Log("Worldmanager in network");
}```
subtle tide
# crimson tartan well, how do i keep it in the hiearchy when switching scenes then

If you have Active scene synchronization check, then i believe that it should move to the new scene

A NetworkObject is a GameObject with a NetworkObject component and at least one NetworkBehaviour component, which enables the GameObject to respond to and interact with netcode. NetworkObjects are session-mode agnostic and used in both client-server and distributed authority contexts.

#

But I use scriptable objects to persist data between scenes

crimson tartan
crimson tartan
subtle tide
polar quarry
#

I'm trying to do something like this:

  • Players click on the Play Button
  • They get together in a room containing the NetworkManager
  • I'd show the available items for each client.

This is done using a LobbyManager class which is in-scene placed. It shows 2 observers on the Inspector but it only exists on the Server, it doesn't exist on the client. I tried to run some code like this below and it doesn't show anything for clients, only for the host.

private void Update()
{
if (IsClient)
Debug.Log($"[Update] ClientId: {NetworkManager.LocalClientId}");
}

#

@subtle tide if you know a workaround, it'd be really helpful, you're such a knowledgeable guy about Unity ๐Ÿ™‚