mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Include rotation in body alignment calculations
This commit is contained in:
parent
7449b7e0f2
commit
ee99c5e937
@ -144,16 +144,6 @@ namespace NewHorizons.Builder.Props
|
|||||||
// Items shouldn't use these else they get weird
|
// Items shouldn't use these else they get weird
|
||||||
if (isItem) detail.keepLoaded = true;
|
if (isItem) detail.keepLoaded = true;
|
||||||
|
|
||||||
|
|
||||||
if (detail.alignToNormal)
|
|
||||||
{
|
|
||||||
Quaternion rot = detail.rotation == null ? Quaternion.identity : Quaternion.Euler(detail.rotation);
|
|
||||||
// Apply the rotation after aligning it with normal
|
|
||||||
var up = (prop.transform.position - go.transform.position).normalized;
|
|
||||||
prop.transform.rotation = Quaternion.FromToRotation(Vector3.up, up);
|
|
||||||
prop.transform.rotation *= rot;
|
|
||||||
}
|
|
||||||
|
|
||||||
prop.transform.localScale = detail.stretch ?? (detail.scale != 0 ? Vector3.one * detail.scale : prefab.transform.localScale);
|
prop.transform.localScale = detail.stretch ?? (detail.scale != 0 ? Vector3.one * detail.scale : prefab.transform.localScale);
|
||||||
|
|
||||||
if (detail.removeChildren != null)
|
if (detail.removeChildren != null)
|
||||||
|
|||||||
@ -51,8 +51,9 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
if (alignToBody)
|
if (alignToBody)
|
||||||
{
|
{
|
||||||
var planetPos = planetGO.transform.InverseTransformPoint(go.transform.position);
|
var up = (go.transform.position - planetGO.transform.position).normalized;
|
||||||
go.transform.rotation = Quaternion.FromToRotation(Vector3.up, planetGO.transform.TransformDirection(planetPos.normalized)).normalized;
|
go.transform.rotation = Quaternion.FromToRotation(Vector3.up, up);
|
||||||
|
go.transform.rotation *= rot;
|
||||||
}
|
}
|
||||||
return go;
|
return go;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user