Skip to content

Commit

Permalink
Fix for first model transform being misaligned because of different i…
Browse files Browse the repository at this point in the history
…nstantiation process.

This is a fix for the problem discussed at KSP-RO/RealPlume-StockConfigs#81 and PorktoberRevolution/ReStocked#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.
  • Loading branch information
Scialytic committed Jun 7, 2019
1 parent b70dcfe commit 3656070
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ModelMultiShurikenPersistFX.cs
Expand Up @@ -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);
Expand Down Expand Up @@ -1167,4 +1167,4 @@ private float maxInput(int id)

return max;
}
}
}

0 comments on commit 3656070

Please sign in to comment.