Jump to content

how to control vfx explosion from assests


photo

Recommended Posts

Hello @Vineet,

I suppose you intend to spawn an explosion using the vfx_explosions_3 sample from the vfx add-on. This is a compound object consisting of several pre-set Particle Systems and saved as a Node Reference. Once enabled or loaded they emit particles (single-time blast). You can change the Delay value of each particle system for a certain time offset without coding.

image.png

If you intend to implement some logic for enabling the explosion, check out our C# Component System-related resources:

And videotutorials that show how to spawn a node reference:

Basically, you'll need a C# component responsible for spawn via the following code, for example:

Spoiler


public class Spawner : Component
{
    public AssetLinkNode node_to_spawn;
    public vec3 spawn_position = vec3.ZERO;
	public float period = 3.0f;

	private float timer;

    private void Init()
	{
		timer = period;
	}

    private void Update()
    {
		timer -= Game.IFps;
        if (timer < 0)
		{
            spawn();
			timer = period;
		}
    }

    private void spawn()
    {
        if (!node_to_spawn.IsNull && node_to_spawn.IsFileExist)
            node_to_spawn.Load(vec3.ZERO);
    }
}

 

Don't forget also to handle deletion of spawned objects.

Thanks!

Link to comment
×
×
  • Create New...