public class LocalPlayerController : PlayerController {
[System.NonSerialized]
public TNObject tno;
public override void Start()
{
tno = GetComponent<TNObject>();
if (tno.isMine)
{
//to prevent players from being stuck in the air when theres no movement / inputs being sent
InvokeRepeating("SyncMyPos", 1.5f, 1.5f);
base.Start();
}else this.enabled = false;
}
public void SyncMyPos()
{
if(tno.isMine)
tno.SendQuickly(1, Target.Others, transform.position, transform.rotation, state);
}
public override void Update()
{
if (tno.isMine)
{
base.Update();
if (base.moveDirection.x != 0 || base.moveDirection.z != 0 || base.moveDirection.y >= 0 || base.velMagnitude >= 3f)
{
tno.SendQuickly(1, Target.Others, transform.position, transform.rotation, base.state);
}
}
}
[RFC(1)]
public void UpdatePlayer(Vector3 pos, Quaternion rot, int playerState)
{
if (tno.isMine) return;
Vector3 newpos = Vector3.Lerp(transform.position, pos, 5f);
Quaternion newrot = Quaternion.Slerp(transform.rotation, rot, 5f);
int NewPlayerState = playerState;
transform.position = newpos;
transform.rotation = newrot;
}
}