Controlling particles via script?

Materials, textures, lighting, postfx
9 posts Page 1 of 1
saindd
Posts: 220
Joined: Wed Apr 15, 2015 3:20 am
by saindd » Fri Jun 12, 2015 3:17 pm
I'm trying to replace the old mesh-based muzzle flash code with a particle-based one. How can i instance and control particles from scripts?
LukasPJ
Site Admin
Posts: 382
Joined: Tue Feb 03, 2015 7:25 pm
 
by LukasPJ » Fri Jun 12, 2015 6:16 pm
Can you elaborate? The current system is pretty much bound to emitting particles in spherical volumes. It can't do more than that so if you mean you want to control specific particles individually through script then that is not currently possible without the ParticleRefactor afaik.

If you just want to spawn a ParticleEmitter, well then that's basically how you do it.
You can't spawn a ParticleEmitter by itself, what you need to do (if you're working purely from script) is to spawn a ParticleEmitterNode and mount it to the gun whereever you need it to be, and give the Node a reference to the desired ParticleEmitterDatablock.
saindd
Posts: 220
Joined: Wed Apr 15, 2015 3:20 am
by saindd » Fri Jun 12, 2015 8:03 pm
Can i control the spawned ParticleEmitter via script? Play, stop, change it's parameters? For example, i might want to randomize some of the properties, like velocity, etc.

Are there any examples of ParticleEmitterNode in the docs?
LukasPJ
Site Admin
Posts: 382
Joined: Tue Feb 03, 2015 7:25 pm
 
by LukasPJ » Fri Jun 12, 2015 8:59 pm
Can i control the spawned ParticleEmitter via script? Play, stop, change it's parameters? For example, i might want to randomize some of the properties, like velocity, etc.

Are there any examples of ParticleEmitterNode in the docs?
The issue is that, all of those parameters are datablock-parameters. So it's messy to change those values at run-time, since it doesn't copy the values from the datablock, but uses the values directly from those datablocks.

There are plenty examples of both ParticleEmitterNode and ParticleEmitter here and there. You can use this part of my "Coin Collection Tutorial" for an introduction on how to create ParticleEmitter's at run-time. http://wiki.torque3d.org/coincollection:visualeffects
saindd
Posts: 220
Joined: Wed Apr 15, 2015 3:20 am
by saindd » Fri Jun 12, 2015 10:04 pm
Thanks. Do you think it's reasonable to use that as a muzzle-effect base or should i create a custom class? In UE, i use particles as muzzle flashes instead of meshes inside the models. This way, the same effect applies to both FP and TP.
Azaezel
Posts: 395
Joined: Tue Feb 03, 2015 9:50 pm
 
by Azaezel » Sat Jun 13, 2015 6:55 am
Sounds like you're more looking to alter https://github.com/GarageGames/Torque3D ... er.cs#L456

The fixed values would be defined https://github.com/GarageGames/Torque3D ... s#L79-L122

What all are you looking to alter in terms of variation?
saindd
Posts: 220
Joined: Wed Apr 15, 2015 3:20 am
by saindd » Sat Jun 13, 2015 5:56 pm
Randomization of rotation, size and life of the particles, so each shot can have a slightly different muzzle flash.
Azaezel
Posts: 395
Joined: Tue Feb 03, 2015 9:50 pm
 
by Azaezel » Sun Jun 14, 2015 5:59 pm
That'll be coverded by http://imgur.com/vEp4z6F,2CjHW1m then by and large.

Do note that size[x] and time[x] are linked, so to use that one as an example, it starts at .4 size, halfway through the lifetime of a given particle it's at 1.2, and at the end it's about 1.7. Given it's time-based, variance in life time will put that at different sizes, though obviously, longer lasting particles will spread further out.

Spin min/max sets it up the parameters of the initial random distribution.

Liferandom for the *emitter* will give variance on the overarching particle system, not the individual ones.

Amount and amount random it should be noted are *frequency* settings, so lower = more spam.
saindd
Posts: 220
Joined: Wed Apr 15, 2015 3:20 am
by saindd » Sun Jun 14, 2015 6:55 pm
Now i get it. Thanks! :)
9 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest