Alek/floating bodies (#48)

* spawning all remote synced objects in sun - also moving to sun if in center
This commit is contained in:
AmazingAlek 2020-03-02 20:44:44 +01:00 committed by GitHub
parent 26dd171a2b
commit 7b707be963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -25,6 +25,11 @@ namespace QSB
_shipPrefab.AddComponent<ShipTransformSync>(); _shipPrefab.AddComponent<ShipTransformSync>();
spawnPrefabs.Add(_shipPrefab); spawnPrefabs.Add(_shipPrefab);
ConfigureNetworkManager();
}
private void ConfigureNetworkManager()
{
networkAddress = QSB.DefaultServerIP; networkAddress = QSB.DefaultServerIP;
maxConnections = MaxConnections; maxConnections = MaxConnections;
customConfig = true; customConfig = true;

View File

@ -37,6 +37,10 @@ namespace QSB.TransformSync
transform.parent = Locator.GetRootTransform(); transform.parent = Locator.GetRootTransform();
_syncedTransform = hasAuthority ? InitLocalTransform() : InitRemoteTransform(); _syncedTransform = hasAuthority ? InitLocalTransform() : InitRemoteTransform();
if (!hasAuthority)
{
_syncedTransform.position = Locator.GetAstroObject(AstroObject.Name.Sun).transform.position;
}
} }
private void SetFirstSector() private void SetFirstSector()
@ -66,10 +70,17 @@ namespace QSB.TransformSync
} }
else else
{ {
_syncedTransform.parent = sectorTransform; if (_syncedTransform.position == Vector3.zero)
{
_syncedTransform.position = Locator.GetAstroObject(AstroObject.Name.Sun).transform.position;
}
else
{
_syncedTransform.parent = sectorTransform;
_syncedTransform.localPosition = Vector3.SmoothDamp(_syncedTransform.localPosition, transform.position, ref _positionSmoothVelocity, SmoothTime); _syncedTransform.localPosition = Vector3.SmoothDamp(_syncedTransform.localPosition, transform.position, ref _positionSmoothVelocity, SmoothTime);
_syncedTransform.localRotation = QuaternionHelper.SmoothDamp(_syncedTransform.localRotation, transform.rotation, ref _rotationSmoothVelocity, Time.deltaTime); _syncedTransform.localRotation = QuaternionHelper.SmoothDamp(_syncedTransform.localRotation, transform.rotation, ref _rotationSmoothVelocity, Time.deltaTime);
}
} }
} }
} }