mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
Smoother movement
This commit is contained in:
parent
1c302a931f
commit
752f747275
@ -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;
|
||||
}
|
||||
}
|
||||
|
21
QSB/QSB.cs
21
QSB/QSB.cs
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user