From 752f74727594ad088125b5eb04ee85073a17775a Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Tue, 11 Feb 2020 13:57:43 +0100 Subject: [PATCH] Smoother movement --- QSB/NetworkPlayer.cs | 3 ++- QSB/QSB.cs | 21 --------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/QSB/NetworkPlayer.cs b/QSB/NetworkPlayer.cs index 0f4dc411..2a55bf81 100644 --- a/QSB/NetworkPlayer.cs +++ b/QSB/NetworkPlayer.cs @@ -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; } } diff --git a/QSB/QSB.cs b/QSB/QSB.cs index 6fa9f658..09f7ad04 100644 --- a/QSB/QSB.cs +++ b/QSB/QSB.cs @@ -21,9 +21,6 @@ namespace QSB { void Start () { _instance = this; - ModHelper.Events.Subscribe(Events.AfterStart); - ModHelper.Events.OnEvent += OnEvent; - var assetBundle = ModHelper.Assets.LoadBundle("assets/network"); var networkManager = Instantiate(assetBundle.LoadAsset("assets/networkmanager.prefab")); var networkPlayerPrefab = assetBundle.LoadAsset("assets/networkplayer.prefab"); @@ -31,24 +28,6 @@ namespace QSB { networkManager.GetComponent().playerPrefab = networkPlayerPrefab; } - void OnEvent (MonoBehaviour behaviour, Events ev) { - var player = GameObject.Find("Traveller_HEA_Player_v2"); - - var spawn1 = Locator.GetPlayerBody().gameObject; - spawn1.AddComponent(); - var spawn2 = Locator.GetShipBody().gameObject; - spawn2.AddComponent(); - - var networkIdentity = player.AddComponent(); - networkIdentity.localPlayerAuthority = true; - - var networkTransform = player.AddComponent(); - - var networkManager = gameObject.AddComponent(); - networkManager.playerPrefab = player; - var networkHUD = gameObject.AddComponent(); - } - public static void Log (params string[] strings) { _instance.ModHelper.Console.WriteLine(string.Join(" ", strings)); }