I have a project where I want a space ship to blow up, and the explosion particles to inherit the ship’s velocity.
I have the particle system parented to the ship, and call Play(), then unparent the particle system, then I remove the ship from the scene (all on the same frame)… and my explosion won’t move!!
However! If I wait even a single frame after calling Play() to unparent the particle system and remove the ship, then the explosion DOES move as desired.
How can I have the explosion inherit velocity immediately, so I don’t have to write code to allow the ship to live for an extra frame just to get this to work?
Try calling Emit on the particle system to force the particles to fire immediately. Otherwise, it might just be a quirk of the particle system in general.
Thanks but no, that doesn’t change anything. The particles emit just fine on the initial frame (with either Play() or Emit()), but they don’t seem to inherit the velocity of the parent until the subsequent FixedUpdate?
Is this by design (because if so the docs are incorrect) or am I missing something?
I found this thread with info on how it looks like the inherit velocity module works today:
Relevant info:
Since the local velocity doesn’t come directly from the rigidbody, it must still be using the same velocity calculation mentioned earlier in the post, while using local space.
So since local velocity needs both old position and current position, that sounds like it needs 2 frames before local velocity of the particle system can be calculated. So on the 2nd frame we now have local velocity, so we calculate the overall velocity by subtracting it from rigidbody velocity… But oops!!! The rigidbody was destroyed at the end of last frame, so can’t do the calculation. Without a parent, I think that breaks calculating local velocity on the 2nd frame as well.