mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix primary body stuff
This commit is contained in:
parent
8606b8a5b6
commit
2ad9784b34
@ -62,6 +62,12 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, PlanetConfig config)
|
||||
{
|
||||
if (config.Orbit.primaryBody == null)
|
||||
{
|
||||
NHLogger.LogError($"Comet {planetGO.name} does not orbit anything. That makes no sense");
|
||||
return;
|
||||
}
|
||||
|
||||
var rootObj = new GameObject("CometRoot");
|
||||
rootObj.SetActive(false);
|
||||
rootObj.transform.parent = sector?.transform ?? planetGO.transform;
|
||||
@ -77,7 +83,10 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
Delay.FireOnNextUpdate(() =>
|
||||
{
|
||||
controller.SetPrimaryBody(AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform);
|
||||
controller.SetPrimaryBody(
|
||||
AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform,
|
||||
AstroObjectLocator.GetAstroObject(config.Orbit.primaryBody).GetAttachedOWRigidbody()
|
||||
);
|
||||
});
|
||||
|
||||
controller.SetScaleCurve(cometTailModule.curve);
|
||||
|
||||
@ -6,7 +6,8 @@ namespace NewHorizons.Components.SizeControllers
|
||||
{
|
||||
public class CometTailController : SizeController
|
||||
{
|
||||
private Transform _primaryBody;
|
||||
private Transform _dustTargetBody;
|
||||
private OWRigidbody _primaryBody;
|
||||
private OWRigidbody _body;
|
||||
|
||||
private bool _hasRotationOverride;
|
||||
@ -38,8 +39,8 @@ namespace NewHorizons.Components.SizeControllers
|
||||
|
||||
private void UpdateTargetPositions()
|
||||
{
|
||||
var toPrimary = (_body.transform.position - _primaryBody.transform.position).normalized;
|
||||
var velocityDirection = -_body.GetVelocity(); // Accept that this is flipped ok
|
||||
var toPrimary = (_body.transform.position - _dustTargetBody.transform.position).normalized;
|
||||
var velocityDirection = (_primaryBody?.GetVelocity() ?? Vector3.zero) -_body.GetVelocity(); // Accept that this is flipped ok
|
||||
|
||||
var tangentVel = Vector3.ProjectOnPlane(velocityDirection, toPrimary) / velocityDirection.magnitude;
|
||||
|
||||
@ -53,9 +54,10 @@ namespace NewHorizons.Components.SizeControllers
|
||||
transform.localRotation = Quaternion.Euler(eulerAngles);
|
||||
}
|
||||
|
||||
public void SetPrimaryBody(Transform primaryBody)
|
||||
public void SetPrimaryBody(Transform dustTarget, OWRigidbody primaryBody)
|
||||
{
|
||||
_hasPrimaryBody = true;
|
||||
_dustTargetBody = dustTarget;
|
||||
_primaryBody = primaryBody;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user