From 36560709235d8a12cd10e399cada8fd03ab6edbc Mon Sep 17 00:00:00 2001 From: Scialytic Date: Fri, 7 Jun 2019 18:05:16 -0400 Subject: [PATCH] Fix for first model transform being misaligned because of different instantiation process. This is a fix for the problem discussed at https://github.com/KSP-RO/RealPlume-StockConfigs/pull/81 and https://github.com/PorktoberRevolution/ReStocked/issues/533 I'm not sure if this was always an issue that just went unnoticed, or if Unity changed something, but whatever the case it is now necessary to set worldPositionStays false. See https://docs.unity3d.com/ScriptReference/Transform.SetParent.html In the old ModelMultiParticlePersistFX all the emitterGameObjects were instantiated off the original GameObject model and then model was destroyed at the end. ModelMultiShurikenPersistFX instead opts to transform model for use as the first emitterGameObject and only instantiate more starting with the second transform if the engine has multiple transforms. However, with worldPositionStays true (the default) parent-relative position, scale and rotation are modified so the first transform may end up out of alignment with the subsequent ones. --- ModelMultiShurikenPersistFX.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ModelMultiShurikenPersistFX.cs b/ModelMultiShurikenPersistFX.cs index 1939e39..6e7b9eb 100644 --- a/ModelMultiShurikenPersistFX.cs +++ b/ModelMultiShurikenPersistFX.cs @@ -651,7 +651,7 @@ public override void OnInitialize() DisableCollider(pkpe.go); - emitterGameObject.transform.SetParent(transforms[i]); + emitterGameObject.transform.SetParent(transforms[i], false); emitterGameObject.transform.localPosition = localPosition; emitterGameObject.transform.localRotation = Quaternion.Euler(localRotation); @@ -1167,4 +1167,4 @@ private float maxInput(int id) return max; } -} \ No newline at end of file +}