Game Development Community

Change Particle Emitter Area in Code

by Andrew Deters · in Torque 2D Beginner · 01/11/2015 (9:28 pm) · 6 replies

I have an emitter with EmitterType = "BOX". I would like to know if there is a way to change the the EmitterSize field in code so I can use the emitter for different sized events. I only need 3 different sizes so I know I could just make 3 different sized emitters, but I do not like that Idea. Also knowing how to change the EmitterSize in code would be very useful and make it more flexible. I know this was an option in the payed versions of Torque 2D, but I just can't figure out the new way things like this are done. As well I have looked at the emitter documentation, and have found nothing that I can use for this issue. I could have missed something, so please let me know. Thank you.

#1
01/11/2015 (10:45 pm)
Not to seem like a smart alec, but have you tried setting the size?
%myEmitter.Size = "5.0 5.0 5.0";
I have not, but it should work.
#2
01/11/2015 (11:11 pm)
I did try that, and it had no effect. Also I know I can set a scale factor to it, but that's not what I need. I need to be able to set the x and y independently.
#3
01/12/2015 (3:51 am)
There is a way to change the EmitterSize field in code - but Richard's example has a mistake in it as the field is called EmitterSize and not Size. There's also setEmitterSize and getEmitterSize methods available to ParticleAssetEmitter.
#4
01/12/2015 (6:07 am)
Ah hah! Yes, ::Size would change the size of the object itself and not the emitter. Mike is spot on, of course.
#5
01/12/2015 (11:37 am)
I think I saw the setEmitterSize method, but I could not figure out how to use it properly.
#6
01/16/2015 (2:21 pm)
%effect = new ParticlePlayer();
        %effect.Particle = "Assets:ParticleAsset1";
        %effect.setPosition(%OtherObject.getposition());

        // I know this is wrong, but I don't Know the right way
        %emitter = %effect.getEmitter(0);
        %emitter.setEmitterSize(%OtherObject.size);
        
        GameScene.add( %effect );
        %effect.play();

when I run this I get errors saying "Unknown command getEmitter"