Skip to main content
stormingdecker
Inspiring
April 6, 2025
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!!

PigeonNo12
Honored Contributor
April 10, 2025

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. 

Upcoming Events : Build with a Mentor: Custom UI Thursday 3/20 at 5:00 PM PT Register March calendar of all Mentor Workshops and Office Hours

4 replies

PigeonNo12
Honored Contributor
April 10, 2025

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. 

Upcoming Events : Build with a Mentor: Custom UI Thursday 3/20 at 5:00 PM PT Register March calendar of all Mentor Workshops and Office Hours
stormingdecker
Inspiring
April 10, 2025

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!

New Participant
May 11, 2025

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
Sibi
stormingdecker
Inspiring
May 12, 2025

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