saindd Posted June 12, 2015 Share Posted June 12, 2015 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? Quote Link to comment Share on other sites More sharing options...
LukasPJ Posted June 12, 2015 Share Posted June 12, 2015 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. Quote Link to comment Share on other sites More sharing options...
saindd Posted June 12, 2015 Author Share Posted June 12, 2015 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? Quote Link to comment Share on other sites More sharing options...
LukasPJ Posted June 12, 2015 Share Posted June 12, 2015 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 Quote Link to comment Share on other sites More sharing options...
saindd Posted June 12, 2015 Author Share Posted June 12, 2015 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. Quote Link to comment Share on other sites More sharing options...
Azaezel Posted June 13, 2015 Share Posted June 13, 2015 Sounds like you're more looking to alter https://github.com/GarageGames/Torque3D/blob/development/Templates/Full/game/art/datablocks/weapons/Lurker.cs#L456The fixed values would be defined https://github.com/GarageGames/Torque3D/blob/development/Templates/Full/game/art/datablocks/weapons/Lurker.cs#L79-L122What all are you looking to alter in terms of variation? Quote Link to comment Share on other sites More sharing options...
saindd Posted June 13, 2015 Author Share Posted June 13, 2015 Randomization of rotation, size and life of the particles, so each shot can have a slightly different muzzle flash. Quote Link to comment Share on other sites More sharing options...
Azaezel Posted June 14, 2015 Share Posted June 14, 2015 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. Quote Link to comment Share on other sites More sharing options...
saindd Posted June 14, 2015 Author Share Posted June 14, 2015 Now i get it. Thanks! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.