#ClientRPC call not working

1 messages · Page 1 of 1 (latest)

crisp pumice
#

I have a script on a gameobject called WorldState, e.g. public class WorldState : NetworkBehaviour in this script I have a ClientRPC method, I call this and nothing happens - I have a debug inside and it never gets called. IT does however work if I throw my code on to my player class. I am not sure why it fails to work on the original? do I need to spawn in my gameobject a certain way - I just want this to live in the scene

torpid ermine
crisp pumice
#

im calling it on key press so not that - but thanks

torpid ermine
#

You probably should just be doing the work in OnStartClient of the WorldState script instead

crisp pumice
#

its not even being called on the server itself (playing host+client)

torpid ermine
#

ah - you didn't mention that part

#

under inform, get bad guesses

crisp pumice
#

I can call the method fine if I remove the ClientRpc but of course that defeats the purpose

torpid ermine
#

first, client's can't call ClientRpc

crisp pumice
#

no

#

I have a host

torpid ermine
#

host is client

crisp pumice
#

that is using host+ client so I can play on it

#

I check for IsServer and it passes

torpid ermine
#

don't do that

#

host is a client - treat it as a remote like all the others. It needs to call a Cmd -> ClientRpc like any other client

crisp pumice
#

im not sure about how to do that, I was looking at the mirror docs and just following that - I found the bit where it said ClientRPC should be used to send to clients I guess its not up to date?

#

It said not to use Command for this maybe same issue

torpid ermine
#

do wat ??

crisp pumice
#

mirror docs say ClientRPC should be used to send calls from Server > Clients

#

being I am running the server (even if its also playing) I imagined that was what I should use

#

So you are saying use Command?

torpid ermine
#

again and again - host client is a client - don't make it special by exploiting it being on the server