Getting return value from 'Command'

Hi all,

Trying to get to grips with some networking but apparently I’ve managed to confuse myself in the process.

There’s 2 (seemingly) pretty basic things I’d like to do, and I’m hoping you can shed some insight.

  1. Fixed this issue. Was being silly.

  2. Return values on Commands? Are these possible? I’ve tried so far and had no luck. If not, what is the common methodology behind getting values from the server (short of syncVar…).

Any insight is appreciated, thanks!

if you want to return a value to a specific client, you can send a message to that client from the server

Its a shame, right?
but yeah you cant do that, I use ClientRpc’s so for example if i have a float that’s called “exampleValue” and want to update it on the client you could something like this:

[Command]
public void CmdRecuestNewValues(){
RpcGiveNewValues(exampleValue);
}

[ClientRpc]
public void RpcGiveNewValues(float value){
exampleValue = value;
}

then if you call the CmdRecuestNewValues(); command you will update you values.

You want to use a TargetRPC to return values.

1 Like