- Home /
Question by
snowy6409 · Jul 24, 2019 at 06:37 PM ·
multiplayervr
Cannot sync non player object with server UNET
I am working on creating a VR multiplayer simulation and need both the client and server to be able to pick up and move a part. They can both grab the part however only the server can actually move it fully the client only slightly moves it before forcibly rubber banding back to position. Below is the code for the object. using System.Collections; using System.Collections.Generic; using UnityEngine.Networking; using UnityEngine;
public class Lego : NetworkBehaviour
{
public int Test;
public Quaternion rot;
// Start is called before the first frame update
void Start()
{
}
[ClientRpc]
public void RpcSyncedPos(Vector3 syncedPos, Quaternion syncedRotation)
{
transform.position = syncedPos;
transform.rotation = syncedRotation;
}
[Server]
private void UpdateClientsPos()
{
RpcSyncedPos(transform.position, transform.rotation);
}
void Update()
{
UpdateClientsPos();
}
}
Comment