Recently I decided to make my own network transform component to compensate for the lagginess.
Code:
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
[NetworkSettings (channel = 0, sendInterval = 0.033f)]
public class NetworkTransformSync : NetworkBehaviour {
public bool syncPosition;
public bool syncRotationY;
[SyncVar]
private Vector3 syncPos;
[SyncVar]
private float syncRotY;
public float lerpRate;
void Update () {
TransmitSync ();
}
void FixedUpdate () {
LerpTransform ();
}
void LerpTransform () {
if (!isLocalPlayer)
{
transform.position = Vector3.Lerp (transform.position, syncPos, lerpRate * Time.deltaTime);
transform.rotation = Quaternion.Lerp (transform.rotation, Quaternion.Euler (0, syncRotY, 0), lerpRate * Time.deltaTime);
}
}
[Command]
void CmdSyncTransform () {
if (syncPosition)
{
syncPos = transform.position;
}
if (syncRotationY)
{
syncRotY = transform.rotation.y;
}
}
[ClientCallback]
void TransmitSync () {
if (isLocalPlayer)
{
CmdSyncTransform ();
}
}
}
My only problem is, it only syncs positions to the host. The server does not receive positions and as a result thinks the player is always at 0 0 0. Help?