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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question about Commands

Discussion in 'Multiplayer' started by UnbreakableOne, Oct 27, 2015.

  1. UnbreakableOne

    UnbreakableOne

    Joined:
    Nov 16, 2013
    Posts:
    168
    Hi,

    I have a Command in which I call another function call. Should the 2nd function call be a Command as well? I'm asking because it is not getting called on the clients but only on the host.

    I have a command to make a bullet that instantiates and calls a regular method to initialize that bullet. On the host, both of these gets called but on the client only the Command gets called.

    Thanks
     
  2. SpeakUpGames

    SpeakUpGames

    Joined:
    Nov 25, 2014
    Posts:
    56
    Commands are functions that should be called by client code, to be run on the server. CmdFoo() should be called by clients, the body of CmdFoo() { //code } is run on the server. Functions called within the command are run on the server, except ClientRPCs, which are the exact opposite effect.
     
  3. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I generally command the server to rpc the clients, the clients can't rpc afaik.
     
  4. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669