#rpc not properly working
1 messages ยท Page 1 of 1 (latest)
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
Are you still seeing that object in DDOL, on the client?
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)
as long as worldmanager is spawned on the host, it will get spawned on the client whenever they join
then.. why isn't it ?
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
make sure the DDOL() is being run in OnNetworkSpawn(). Then you will know it spawned
it is..
public override void OnNetworkSpawn()
{
base.OnNetworkSpawn();
DontDestroyOnLoad(this);
Debug.Log("Worldmanager in network");
}```
the debuglog logs on the server but not the client
could be a bug. try removing base.OnNetworkSpawn();
nope, still nothing
it's clearly connected to the server enough to know to change the scene
Its not a singleton is it? I've seen network object singletons destroy themselves on spawn
when i start a client, it gets added as an observer into the host
nope not anymore
so it's showing the client as an observer to the object, but not spawning the object on that client
weird. not sure how that is possible. open a bug report on that
so.. how do i get this working ๐ญ
I would remove the DDOL() for now
well, how do i keep it in the hiearchy when switching scenes then
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");
}```
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
yeah this changes nothing...
and.. how do i do that
https://docs.unity3d.com/Manual/class-ScriptableObject.html
You can save an index of a prefab list on the SO in the first scene then the Spawner script can be in the main game scene that can send an RPC to the server indicating which prefab to spawn
Man, were you able to fix that? I'm on the same page...
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 ๐