Hey there guys,
I’m building a 3D game, just for information. My Charactercontroller is the default unity one, but changed to work in a network. Like disabling other players’ movement for the client.
I’ve got a player, which is networked and everything is fine, except that the movement of clients lags behind like 3-5 seconds, and I have to move with great distance to let the server know I moved. My update rate is ‘9’ of the Network transform, this worked fine with my other projects.
The weird thing is, rotation does work absolutely perfect and is synced well. Does anyone have any idea how to fix this?
Using Unity 2017, but this problem also occurs in unity 2018.
Here’s the code that handles the player camera’s and controls;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityStandardAssets.Characters.FirstPerson;
public class Player : NetworkBehaviour {
public GameObject sceneCam;
// Use this for initialization
void Start () {
if (!isLocalPlayer)
{
gameObject.GetComponent<FirstPersonController>().enabled = false;
Camera[] cams = gameObject.GetComponentsInChildren<Camera>();
AudioListener[] audiol = gameObject.GetComponentsInChildren<AudioListener>();
gameObject.GetComponent<AudioSource>().enabled = false;
gameObject.GetComponent<CharacterController>().enabled = false;
foreach(Camera cam in cams)
{
cam.enabled = false;
}
foreach(AudioListener audio in audiol)
{
audio.enabled = false;
}
}
if (isLocalPlayer)
gameObject.layer = LayerMask.NameToLayer("LocalPlayer");
else
gameObject.layer = LayerMask.NameToLayer("ExternalPlayer");
}
// Update is called once per frame
void Update () {
}
}
Thank you very much,
Tristan