Search Unity

Clients can't send [Command] from scene objects?!

Discussion in 'Multiplayer' started by Artaani, Sep 10, 2016.

  1. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    423
    Seriously?!

    I am trying to make simple chat.
    I have empty game object in the scene, with checkbox ON for Local Player Authority
    And component "Chat"

    Client connects to server and trying to invoke some [Command], for example CmdSendMessage (string text)
    And warning in the console:
    Trying to send command for object without authority

    What?!
    How I supposed to send request to server from various managers (which located on empty scene objects)?
     
  2. Fahersto

    Fahersto

    Joined:
    Sep 10, 2016
    Posts:
    7
    I'm struggling myself but as far is I read one is only able to call [Command] functions from scripts that are attached to a gameobject with is the "Player Prefab" in the Networkmanager. Did you do that?

    I have a similar problem.. I want to call commands but I don't want to call it on the "Player Prefab".
    I haven't found a solution yet.
     
  3. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    423
    Thanks for reply.
    Yes, seems like it is the only way to call Commands, attach everything to objects which spawned from Network Manager.
    Of course we can do it, but from my opinion, it is completely wrong way. I just don't want to build such architecture.

    Until it will be changed, seems like new network system completely useless. Previous network system is very good.
     
  4. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    423
  5. Fahersto

    Fahersto

    Joined:
    Sep 10, 2016
    Posts:
    7
    I ended up rewriting big parts of my player controlling system just to be able to have a script on the "player prefab" call the command. Maybe I'm missing something (I'm jsut starting with unity). This way im forced to build my architecture way more arround the unet components than I wanted to. I can see why you wouldn't want to do that. It does work now though and is nice for a quick start
     
  6. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    UNET might be afflicted with some constraints as it regards architecture, but IMHO this is by no means reason enough to say that this makes it "completely useless". Also, I think many architectural decisions were made for good reason. Of course, if you have the opinion that particular decisions are bad then this is fine, but you should at least provide a detailed description of the particular issues instead of just saying: "I don't like it this way because it's different than before".

    There is an option to assign client authority for non-player objects. See the docs.

    In particular, there is the AssignClientAuthoriy function. I haven't tested this myself, but I would expect that it also allows to assign authority for pre-placed networked scene objects.
     
    Last edited: Sep 12, 2016