I am in the development of a 2d top down environment. I am using netcode for multiplayer, which will only be for a few people.
I have setup a network manager and added my prefab as a network prefab. My prefab has a network object component attached to it.
I have setup buttons, so that when I build and run the game I can choose between a server, host and client. I have the host on the main environment and the client on the new window that pops up.
My issue is that when my object spawns on the server side, it does not spawn on the client side as well.
My code looks like this.
Can someone help me?
Only the server/host can spawn network objects. If you want your client to spawn an object, you need to call a ServerRpc to tell the server spawn the object. Also, it is not required but for player object, you can use the SpawnAsPlayerObject method to acces them easier in the future. (Each client can only have one player object.)
1 Like
do you have an example of this method? I have an object that spawns fine host/play but not when I play on a remote server. Iām assuming I need to spawn it on the server?