- Home /
Networked player movement very choppy, rotation works fine - UNET
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
Answer by J-F · Jul 17, 2018 at 05:59 AM
If you are using a network transform, then have you tried reducing the movement threshold value?
Also, if the movement is choppy, try tweaking the interpolation factor.
Yes, I have definitely tried those settings. But I discovered that it has to do with the default unity 'Rigidbodyfirstperson controller', I've written my own controller now, and everything just works fine.
$$anonymous$$aybe the default unity one is just too advanced for networking? :?