Forum Discussion

stormingdecker's avatar
4 months ago
Solved

How to control playback of Popcorn particle FX from typescript?

Sorry, first time building in MH. I've been trying to integrate an explosion from the public assets library (one of those PopcornFX asset types), but I haven't found out a way to start and stop playback of the particle effect from code.

Casting to a ParticleGizmo obviously doesn't work, and the play() method doesn't resolve. I'm assuming under-the-hood it's an external Unity asset using a sprite sheet. I haven't found any documentation on this.

How do I sent playback events to it?

Thanks a lot!!

  • The ParticleGizmo should work, as long as you have a prefab selected in the gizmo (it defaults to empty). If you are still experiencing issues with this, feel free to share your code and I'll try to replicate on my end. 

4 Replies

  • The ParticleGizmo should work, as long as you have a prefab selected in the gizmo (it defaults to empty). If you are still experiencing issues with this, feel free to share your code and I'll try to replicate on my end. 

  • Okay, great!
    I may have done wrong then. Will keep digging into it, now that I know it should work and I'm probably doing something silly.

    Thanks, Melissa!

  • Hi, I've had the same issue with ParticleGizmo. This lines helped me: 

    import * as hz from 'horizon/core';
    ...
    const gizmos = p.as(hz.ParticleGizmo);
    gizmos.play();
     
    All the best, Anna
  • Thank you, Anna!
    And yes, Pigeon was right, when I tried again it totally did work. I think my initial issue was merely that I had very little familiarity with both typescript and the HZ APIs, and I have a feeling my typecast might have been a "entity as ParticleGizmo" rather than "entity.as(PartizleGizmo)".
    Now, a few thousand lines of code later for all the various subsystems of my contest map, and that little entity type casting subtlety feels as obvious to me as it was to everyone else with previous experience in that environment two months ago. ๐Ÿ˜…
    I'll take the L. ๐Ÿ˜†
    Thanks for chiming in!!!!