Triggering Visual Effects in Unity
Vložit
- čas přidán 23. 08. 2024
- Continuing from Previous Video:
• Particle Bursts with V...
If you want to start from the beginning, click here:
• Getting Started with V...
Finally, we look at how to trigger our particles during gameplay. We briefly talk about a few different approaches, such as child object triggering, Create/Destroy and Object Pooling.
00:25 - Child Object Triggering
01:20 - Create/Destroy Triggering
04:52 - Object Pooling (brief summary)
06:19 - Triggering Visual Effect in Script
11:13 - Create Destroy Method (option)
Really appreciated this video. Clear, concise and very knowledgeable. Helped me out a bunch. Have subscribed and will be working through all of your content.
The best (and only one, that really helped) tutorial about this topic. i used a vfx to make particles and this showed me how i can use this in certain moments in my game.
To get when the visual effect finishes make a float in the vfx graph called something like "Lifetime" connect it to B in "Set LifetimeRandom" then in your script before you call play on the visual effect set the "Lifetime" property you created to the maximum lifetime you want like this "effect.SetFloat("Lifetime", x);" then you can destroy it after whatever x value you set
Or even better you can use effect.GetFloat("Lifetime") to get the length set in the properties
Nice content!
Hey, I don't expect an answer since this video is so old, I have a very specific problem where when I call visualEffect.Play(); in a function on another script, the effect isn't called. Everything is set up appropriately, the variable types are all correct, but the only time I can get the vfx to actually play is when I call the play function in the update of the object with the vfx variable itself, do you have any idea what could be going on here?
I've tried having the effect play be called in a function on the script with the visual effect, but even when that other function is called, vfx.Play(); still isn't called.
Anyway thanks for showing all the ways. Im interested in spawning way but it causes lag for some reason, even if theres like burst of 50 particles lol
Instantiating prefab works as it should but it lags 1000 times more than old particle system :/ Wonder if im doing anything wrong
EDIT: I use "GameObject newBurstEffect = Instantiate" instead of "VisualEffect". Maybe that causes lag?
It might be possible to either 1: Use .aliveParticleCount to determine when the effect has completed playing or 2: Get the max lifetime property using .HasFloat & .GetFloat? These are untested, just quick ideas from looking through the documentation. I've also seen something interesting about triggering other particle spawns using GPU Events but they are currently experimental and also idk if they are able to be used for hookups outside of the VFX system.