Game Development Community

missle; knows where to shoot from

by rennie moffat · in Torque Game Builder · 08/24/2009 (5:08 pm) · 3 replies

from the shooter tut, this is a function for the enemy ship.

What I am wondering is how does the enemyMissle now where to shoot from (always the nose of the ship in this case)? This is a precise area where you can not have it shoot out the cockpit right? So how does it know where to fire from?

function EnemyShip::fireMissile(%this)
{
%this.enemyMissile = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = EnemyMissile;
missileSpeed = %this.missileSpeed;
enemy = %this;
};

%this.enemyMissile.fire();
}

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
08/24/2009 (5:44 pm)
It's not in the snippet you posted but in the fire function, you can see that it just sets the missile to the position of the enemy ship and then applies a small offset to get it to come out correctly visually. If you wanted it to fire from somewhere else, you'd just to go and manually tweak the offset until it looked like you wanted it to look.
#2
08/24/2009 (6:11 pm)
oops.
my bad.
thanks.


I noticed misslies were set to a velocity.
check again,
thank you
#3
08/28/2009 (4:55 pm)
I just want to add it is much easier to use linkpoints on your object and call "%this.setPosition(%this.player.getLinkPoint(1));"...That way you aren't tweaking with numbers constantly. The only thing to remember is that linkpoints in the TGB Editor start at 0, but getLinkPoint starts at 1, so in this case in the TGB Editor "player" has a linkpoint called 0, to access it I must call getLinkPoint(1). This makes me nuts, and I'm debating messing with the source code to allow you to give linkpoints names to access them so its much cleaner in the script code. Of course, if this feature already exists and I'm just missing it, please let me know=)