Particles / objects in general
by Link Hughes · in Torque Game Engine · 10/10/2004 (2:41 pm) · 7 replies
Ok, I have written a member function for my ParticleEmitterNode data block that sets the position. The position variable gets set ok, but the object/particle emitter doesn't move unless I go in to the World editor and select the object/particle emitter and press apply. Is there some sort of function I need to call to update the scene/particle emitter so I can see my changes?
#2
10/11/2004 (6:20 pm)
Is there a way to turn particles on and off if they where attached to say a staff ? Like when the player wantas to cast a spell, he waves ther wand and depending on the spell a certain particle comes out. And by the way, is there a way to switch particles while there on the staff or do you have to create different staffs?
#3
10/11/2004 (8:58 pm)
Http://www.garagegames.com/mg/forums/result.forum.php?qtm=particle&qff=b
#4
the original post with the moving emitter stuff
http://www.garagegames.com/mg/forums/result.thread.php?qt=6395
10/12/2004 (10:15 pm)
I read the forum post that shows how to make the emitter move with the player, but I had a question. I see the MendWoundsImage which makes me think this is set up like a weapon, is this the case?the original post with the moving emitter stuff
http://www.garagegames.com/mg/forums/result.thread.php?qt=6395
#5
10/12/2004 (10:17 pm)
And also, is this scheduled every time the player moves? This sounds computationally expensive to me.
#6
like with my game, I want to cast different spells with a staff, so I want to change particle effects in and out. How would I go about doing this?
10/15/2004 (11:48 am)
So, you can't move the emitternode around, it hasd to be attached to a object? So can objects switch emmiters and stuff? like with my game, I want to cast different spells with a staff, so I want to change particle effects in and out. How would I go about doing this?
#7
You can in fact cause a particle emitter to move, but you have to play tricks to do it.
First, setting %obj.position will not do it. It seems logical, but the reason this does not work is that there is no 'is dirty' watch on the position field, thus changing it does not cause it to update the object's transform, which is actually used for determining its render position.
To get the position updated, use the setTransform() method. (ParticleEmitterNodes are children of SceneObject).
Still, this will not work. You have to play one more trick. Re-set the Particle Emitter Node (PEN) scale, and violla... it will move.
All in all, this is a bad way to move your emitter and it is not a smooth way to translate it's position over time. For that, use a mounted emitter, or use a projectile w/ no shape and no onCollision() damage, or... well there are various options, depending on your need.
Need some help on the code? Here is a code snippet from my work in progress EGTGE:
~~~
Transform components ==> "posX poxY posZ rotX rotY rotZ rotTheta"
Lastly, as mentioned, in this case you must ALSO use the setscale() trick:
[HOW]EdM|EGTGE
- Editted to make more clear.
10/15/2004 (1:26 pm)
Link,You can in fact cause a particle emitter to move, but you have to play tricks to do it.
First, setting %obj.position will not do it. It seems logical, but the reason this does not work is that there is no 'is dirty' watch on the position field, thus changing it does not cause it to update the object's transform, which is actually used for determining its render position.
To get the position updated, use the setTransform() method. (ParticleEmitterNodes are children of SceneObject).
Still, this will not work. You have to play one more trick. Re-set the Particle Emitter Node (PEN) scale, and violla... it will move.
All in all, this is a bad way to move your emitter and it is not a smooth way to translate it's position over time. For that, use a mounted emitter, or use a projectile w/ no shape and no onCollision() damage, or... well there are various options, depending on your need.
Need some help on the code? Here is a code snippet from my work in progress EGTGE:
~~~
Transform components ==> "posX poxY posZ rotX rotY rotZ rotTheta"
%myTransform = %obj.getTransform(); %myPosition = getWords( %myTransform, 0 , 2 ); %myRotationVec = getWords( %myTransform, 3 , 5 ); %myRotationTheta = getWord( %myTransform, 6 ); // Move shape +10 in X direction %myNewPosition = vectorAdd( %myPosition , "10 0 0"); %obj.setTransform( %myNewPosition );~~~
Lastly, as mentioned, in this case you must ALSO use the setscale() trick:
%obj.setScale(%obj.scale);
[HOW]EdM|EGTGE
- Editted to make more clear.
Torque Owner Sam3d
And I don't think the emitter actually moves, rather it is destroyed and a new one created at an incremental position.