sarbian / SmokeScreen

BSD 2-Clause "Simplified" License
16 stars 14 forks source link

Fix for first model transform being misaligned... #32

Closed Scialytic closed 5 years ago

Scialytic commented 5 years ago

...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.

As shown in the screenshots below, with this fix the thrustTransforms are now aligned:

screenshot0-crop

screenshot2-crop

sarbian commented 5 years ago

Thanks for the fix. I ll try to have a release out soon