mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Initial velocity is wrong
This commit is contained in:
parent
97f104852a
commit
7d6ebc959a
@ -137,6 +137,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
prop.transform.localScale = info.scale != 0 ? Vector3.one * info.scale : prefab.transform.localScale;
|
prop.transform.localScale = info.scale != 0 ? Vector3.one * info.scale : prefab.transform.localScale;
|
||||||
|
|
||||||
|
if (info.hasPhysics) AddPhysics(prop, sector);
|
||||||
|
|
||||||
prop.SetActive(true);
|
prop.SetActive(true);
|
||||||
|
|
||||||
return prop;
|
return prop;
|
||||||
@ -293,5 +295,28 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void AddPhysics(GameObject prop, Sector sector)
|
||||||
|
{
|
||||||
|
var rb = prop.AddComponent<Rigidbody>();
|
||||||
|
var owrb = prop.AddComponent<OWRigidbody>();
|
||||||
|
var kine = prop.AddComponent<KinematicRigidbody>();
|
||||||
|
rb.isKinematic = true;
|
||||||
|
owrb._simulateInSector = sector;
|
||||||
|
owrb._kinematicSimulation = true;
|
||||||
|
owrb._kinematicRigidbody = kine;
|
||||||
|
|
||||||
|
prop.AddComponent<InitialMotion>();
|
||||||
|
prop.AddComponent<MatchInitialMotion>().SetBodyToMatch(prop.GetComponentInParent<OWRigidbody>());
|
||||||
|
prop.AddComponent<CenterOfTheUniverseOffsetApplier>();
|
||||||
|
|
||||||
|
var detector = new GameObject("Detector");
|
||||||
|
detector.transform.parent = prop.transform;
|
||||||
|
detector.transform.localPosition = Vector3.zero;
|
||||||
|
|
||||||
|
var shape = detector.AddComponent<SphereShape>();
|
||||||
|
detector.AddComponent<DynamicForceDetector>();
|
||||||
|
detector.AddComponent<ForceApplier>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
5
NewHorizons/External/Modules/PropModule.cs
vendored
5
NewHorizons/External/Modules/PropModule.cs
vendored
@ -210,6 +210,11 @@ namespace NewHorizons.External.Modules
|
|||||||
/// Should this detail stay loaded even if you're outside the sector (good for very large props)
|
/// Should this detail stay loaded even if you're outside the sector (good for very large props)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool keepLoaded;
|
public bool keepLoaded;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Should this object dynamically move around
|
||||||
|
/// </summary>
|
||||||
|
public bool hasPhysics;
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user