#RPC trouble
1 messages · Page 1 of 1 (latest)
heres the serverside code
im new to unity networking and trying to figure out what Im doing wrong.
What's the issue?
its not firing
client clicks button > no debug log on server
current setup is a exe client and editor host
Console warnings? Errors?
none
although I can flip the test again and check
it runs on the client and not the server for some reason
Both Debug Logs run on the client?
yes
That's.. not possible. Unless your client is the host.
You sure you have a valid set up going? A Host/Server starting up properly and a client making a valid connection?
Well unless I'm missing something incredibly obvious, there's not much else I can help with without more information.
Server RPCs are pretty simple in NGO. Call one from a client in order to run the function on the server.
Can you show me the script Respawn() is defined in?
That would be my first guess, yeah.
is there a simple workaround or are my game systems going to have to be network objects?
You can use Singletons or Events if you want to send a message from a MonoBehaviour to a NetworkBehaviour
But yeah, where you can it's not a bad idea to organize networking logic in to NetworkBehaviours
so, if i called a regular method in the network manager that called an rpc on itself, that would probably be a solution.
thanks for the help, testing
@spring sparrow does the GameObject that has PauseMenu on it have a NetworkObject component on it?
yes it does
but at this point im calling the rpc on the networkmanager object so..... it shouldnt matter
Right. But if that's the case PauseMenu doesn't need to have one or be a NetworkBehaviour.
This usually is the result of:
No NetworkObject on a GameObject that's in the hierarchy
A NetworkObject Prefab that's spawned at runtime isn't in the NetworkManagers list
Server isn't active
The network manager can not have a network object on it. You will need to put your pause menu script on a separate Network Object.
Also before you to too far into this. Pausing a network game is going to be a bad time
its just a menu, it doesnt have a pause function.
why do they have to make everything difficult? is it hard to grasp the concept of something other than the player character firing network methods?
Why does that make it difficult?
what if I dont want to stuff literally everything in the player script?
it doesn't have to be a player object
Then make another script that is a NetworkBehaviour. Just don't do it on the NetworkManager..
it just needs a network object
which means i have to make another sub object to handle all the network stuff
which is what the network manager is supposed to be
the new object that I create for all of this also has to be spawned on server side, so i cant even set these up in the editor it looks like, they need to be spawned
which means no setting up references in the editor.
A NetworkObject placed in the hierarchy in editor spawns automatically at runtime when anybody connects.
the player object
but instead of making it a player object it has to be all the background networking stuff on that object
meaning you now have to spawn a second object for the actual player.
it would be nicer if i could just call methods from any object.
unreal does the same shit.
The NetworkManager in multiple networking libraries handles all of the connection related things for you and should not have any game logic on it. That's just common practice.
You can as long as it has a network object component on it
I dont want to havbe 5 global objects just to handle game functions.
thanks for the help, ill do more testing today.
then just use one in scene network object
also look into Custom Messages instead of RPCs
https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/message-system/custom-messages/
A brief explanation of Custom Messages use in Netcode for GameObjects (Netcode) covering Named and Unnamed messages.
oh thank god
No one said you have to do that. Make a NetworkObject with a script like GameManager : NetworkBehaviour and place it in scene. No reason that can't do what you want it to do.
I still have to spawn that object through code, cant just leave it in the scene
right?
@spring sparrow
you can absolutely just leave it in the scene
alright, ill look into it.