Search Unity

Send Command without object authority

Discussion in 'Multiplayer' started by idcanu, Mar 15, 2018.

  1. idcanu

    idcanu

    Joined:
    Jul 3, 2017
    Posts:
    14
    I'm using Unity's Network Lobby for my lobby scene.In Local Multiplayer i want to send Command from other player on which i don't have authority(HasAuthority=false).As Unity docs say "Commands are sent from player objects on the client to player objects on the server. For security, Commands can only be sent from YOUR player object, so you cannot control the objects of other players". I tried AssignClientAuthority to my localplayer but get error of "AssignClientAuthority can only be call on the server for spawned objects."
    So What is exact solution for this?
     
  2. Driiade

    Driiade

    Joined:
    Nov 21, 2017
    Posts:
    80
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    When I want to send a command that makes sense to be on an object that isn't that client's player object or I don't have authority over, I just add a command to a script on the player object, call that, and then have the command call a function on the object I really wanted to call on.

    I like this limitation in theory, because it can help reduce the number of possible cheats in your game and can expose various mistakes you're making in your networking code, but in practice it would be better if there was a way to override this feature. Maybe they could have made a separate UnsafeCommand or something, but they didn't and I don't want to build my own HLAPI dll's to add it.
     
  4. Ellernate

    Ellernate

    Joined:
    Aug 25, 2017
    Posts:
    81
    I just use NetworkMessage. Yea, it would be a lot better to have an UnsafeCommand
     
  5. Driiade

    Driiade

    Joined:
    Nov 21, 2017
    Posts:
    80
    I dont understand where is the security if almost every project need to do that and can do that by bypassing the limitation with command on localplayer....
     
  6. idcanu

    idcanu

    Joined:
    Jul 3, 2017
    Posts:
    14