public void _Update(ShipCtrl.KeyFrameSyncInfo last_kf, float currTime) { float last_sync_client_ts = last_kf.ts - server_start_ts + client_start_ts; Vector2 pos = NextPos(last_kf, Time.time - last_sync_client_ts); Util.SetTfm(transform, pos.x, pos.y, last_kf.angle); }
private Vector2 NextPos(ShipCtrl.KeyFrameSyncInfo synckf, float nextTimeSpan) { Quaternion quaternion = Quaternion.AngleAxis(synckf.angle * Mathf.Rad2Deg, Vector3.down); Vector3 vel = quaternion * Vector3.forward; Vector3 distance = vel.normalized * synckf.speed * nextTimeSpan * 1.2f; return(synckf.pos + new Vector2(distance.x, distance.z)); }