Smoother movement

This commit is contained in:
Ricardo Lopes 2020-02-11 13:57:43 +01:00
parent 1c302a931f
commit 752f747275
2 changed files with 2 additions and 22 deletions

View File

@ -5,6 +5,7 @@ namespace QSB {
public class NetworkPlayer: NetworkBehaviour {
Transform _body;
Transform _sun;
float _smoothSpeed = 10f;
void Start () {
QSB.Log("Started network player");
@ -29,7 +30,7 @@ namespace QSB {
transform.position = _body.position - _sun.position;
transform.rotation = _body.rotation * Quaternion.Inverse(_sun.rotation);
} else {
_body.position = _sun.position + transform.position;
_body.position = Vector3.Lerp(_body.position, _sun.position + transform.position, _smoothSpeed * Time.deltaTime);
_body.rotation = transform.rotation * _sun.rotation;
}
}

View File

@ -21,9 +21,6 @@ namespace QSB {
void Start () {
_instance = this;
ModHelper.Events.Subscribe<PlayerBody>(Events.AfterStart);
ModHelper.Events.OnEvent += OnEvent;
var assetBundle = ModHelper.Assets.LoadBundle("assets/network");
var networkManager = Instantiate(assetBundle.LoadAsset<GameObject>("assets/networkmanager.prefab"));
var networkPlayerPrefab = assetBundle.LoadAsset<GameObject>("assets/networkplayer.prefab");
@ -31,24 +28,6 @@ namespace QSB {
networkManager.GetComponent<NetworkManager>().playerPrefab = networkPlayerPrefab;
}
void OnEvent (MonoBehaviour behaviour, Events ev) {
var player = GameObject.Find("Traveller_HEA_Player_v2");
var spawn1 = Locator.GetPlayerBody().gameObject;
spawn1.AddComponent<NetworkStartPosition>();
var spawn2 = Locator.GetShipBody().gameObject;
spawn2.AddComponent<NetworkStartPosition>();
var networkIdentity = player.AddComponent<NetworkIdentity>();
networkIdentity.localPlayerAuthority = true;
var networkTransform = player.AddComponent<NetworkTransform>();
var networkManager = gameObject.AddComponent<NetworkManager>();
networkManager.playerPrefab = player;
var networkHUD = gameObject.AddComponent<NetworkManagerHUD>();
}
public static void Log (params string[] strings) {
_instance.ModHelper.Console.WriteLine(string.Join(" ", strings));
}