Game Development Community

Adding a particle to the missile in the scroller demo?

by AzraelK · in Torque Game Builder · 08/22/2006 (8:52 am) · 4 replies

Ive tried to add this code to the scroller demo tutorial which (suposedly) adds a smoke and sparkles trail to our players missiles, unfortunately I cant get it to work, what am I doing wrong?

function playerMissile::fire(%this)
{
%this.setWorldLimit( kill, "-195 -162 195 158" );
%this.setLinearVelocityX(%this.missileSpeed);
%this.setPosition(%this.player.getPosition());
%this.setImageMap(playerMissileImageMap);
%this.setSize(12, 6);
%this.setCollisionActive( true, true );
%this.setCollisionPhysics(false, false);
%this.setCollisionCallback(true);
  %thruster = new t2dParticleEffect() { scenegraph = t2dScene; };
  %thruster.loadEffect("~/data/particles/jet.eff");
  %thruster.mount( %this, 0, 0, false );
  %thruster.playEffect();
}

Any help would be appreciated.

Ps. how can I make the shooter load a different level when 10 enemy ships are defeated?

#1
08/22/2006 (1:44 pm)
I got this to work! let me share the finding with you guys

What I had to do was to create another class which holds the Missile Trail then I created a new member inside the player ship and mount the trail to the missile the code is like this.

function playerShip::createMissile(%this)
{
if(!%this.isDead)
{
%this.playerMisil = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = playerMisil;
missileSpeed=%this.missileSpeed;
player = %this;
};
%this.misilTail= new t2dParticleEffect() 
{ 
	scenegraph = %this.scenegraph;
	class= misilTail;
	missileSpeed=%this.missileSpeed;
	player=%this;
};
%this.playerMisil.fire();
%this.misilTail.fire();
%this.misilTail.mount(%this.playerMisil,0,0,false); //this is where the mount the trail to the missile
}

We also need a misilTrail class so I added this misilTrail.cs file too it basically mimics the playerMissile code

function misilTail::fire(%this){
  %this.loadEffect("~/data/particles/jet.eff");
  %this.playEffect(); 
  //%this.setLinearVelocityX(%this.missileSpeed);
  %this.setPosition(%this.player.getPosition());
}


Presto! it probably is not the most elegant solution but it works.
#2
08/30/2006 (11:10 am)
This is cool, cheers!

How would you edit the effect so it doesn't stretch across the screen?

cheers chaps
#3
08/30/2006 (11:44 am)
Thanks!
It is very simple, you only have to modify the life base of the particles (in the graph), so they dont last too much, or you could also modify the visibility so they dissapear quicker . In my case I did wanted the missile smoke streak so I added more life to the smoke and less to the fire emitter.
#4
08/31/2006 (12:28 am)
Thanks Mate!

Im just trying to get to grips with all this, and your help is very much appreciated!