Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Forge] Owner change Serialized Custom Instance Variables

Discussion in 'Multiplayer' started by Smoozilla, Mar 28, 2016.

  1. Smoozilla

    Smoozilla

    Joined:
    Apr 19, 2015
    Posts:
    2
    So I have looked everywhere for this, hopefully someone can point me in the right direction.

    I've been using the free version of Forge to give it a test, I have my NetworkedMonoBehavior searalizing variables like this:


    void Awake()
    {
    AddNetworkVariable(() => DesiredSpeed, x => DesiredSpeed = (float)x);
    AddNetworkVariable(() => DesiredRotation, x => DesiredRotation = (Quaternion)x);
    AddNetworkVariable(() => Moving, x => Moving = (bool)x);
    }

    and in my OwnerUpdate() I am changing these variables. It works playing on the server, but when connecting from a client, the server will not update these values, the client will try to move but server (being authoritative) will lock them in place. These are values I want the owner to have full control over in exactly the way they are supposed to work (only updating on a change), but it seems the server has control on these values. Do I need to put in RPCs to force these updated?

    I want the owner to have final say on these values, and tell the server what they should be.
    How do I accomplish this?

    Thanks

    P.S. I'm Instantiating on the server and changing the owner to the connection, if that makes any difference
     
  2. Smoozilla

    Smoozilla

    Joined:
    Apr 19, 2015
    Posts:
    2
    So it seems by having the NetworkedMonoBehavior as Authoritative, the values won't update from the client. But removing Authoritative is not what I want. Unfortunately it looks like to get what I want I'll have to use Forge client side prediction, and figure out a way to calculate player controls on the server.

    My current player controls use Input.MousePosition and Camera to cast a ray. I can't imagine Input.MousePosition having a value I could use on the server, and since I can't simply NetSync values back to the server when it's Authoritative I might be stuck using RPCs.

    If only I could figure out how to force a NetSync from client owner to server, regardless of Authoritative. Suppose I'll use RPCs for now and check the changed value myself before sending.