Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Getting return value from 'Command'

Discussion in 'Multiplayer' started by Velcrohead, Sep 15, 2015.

  1. Velcrohead

    Velcrohead

    Joined:
    Apr 26, 2014
    Posts:
    78
    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!
     
    Last edited: Sep 15, 2015
  2. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    465
    if you want to return a value to a specific client, you can send a message to that client from the server
     
  3. X606

    X606

    Joined:
    Aug 17, 2016
    Posts:
    2
    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.
     
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    You want to use a TargetRPC to return values.
     
    happirt likes this.