Client controlling server object

So I’m trying to create something that on theory is simple: Server spawn the object and the client control the object that’s updated on server and other clients.

However I can’t even get client control the object to update on server, I can get at maximum the client modifying his own variable. I tried RPC, trying to put Client Network Transform component at object, Network Variable, none seems work.

public NetworkVariable<Vector3> position = new NetworkVariable<Vector3>();
        public Vector3 clientVector = new Vector3(0, 0, 0);

public void Move()
        {
            if (IsClient)
            {
                clientVector = RandomPos();
                UpdatePosServerRpc(clientVector);
            }

        }

        [ServerRpc]
        void UpdatePosServerRpc(Vector3 cV, ClientRpcParams rpcParams = default)
        {
            position.Value = clientVector;
            transform.position = position.Value;

        }

            Vector3 RandomPos()
        {
            //Generate random position
            return new Vector3(Random.Range(-3f, 3f), 1f, Random.Range(-3f, 3f));
        }

The object is spawned by server before this code happens, the server don’t happens to appear any message error.

1 Like

I’m having the same problem. Tried to modify the module one Golden Path code to control the objects on both server and client but I only managed to make it work on the server build. Tried to use both ServerRpc and ClientRpc and it didn’t seem to make a difference.

Also, the Netcode documentation was very poorly updated to match the changes from MLAPI to Netcode until the moment I type this. It’s very common to run through pieces of code that are still using the MLAPI syntax (like the NetworkVariable example), which really makes learning it difficult and/or slow.

1 Like

Is this intended in your ServerRPC Method:

position.Value = clientVector;? Why do you have the Vector3 cv parameter if unused?

1 Like