Initial velocity is wrong

This commit is contained in:
Nick 2022-08-11 22:41:39 -04:00
parent 97f104852a
commit 7d6ebc959a
2 changed files with 30 additions and 0 deletions

View File

@ -137,6 +137,8 @@ namespace NewHorizons.Builder.Props
prop.transform.localScale = info.scale != 0 ? Vector3.one * info.scale : prefab.transform.localScale;
if (info.hasPhysics) AddPhysics(prop, sector);
prop.SetActive(true);
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>();
}
}
}

View File

@ -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)
/// </summary>
public bool keepLoaded;
/// <summary>
/// Should this object dynamically move around
/// </summary>
public bool hasPhysics;
}
[JsonObject]