Plasma Gun
by Robert Rice · in Torque Game Engine · 05/27/2005 (10:30 pm) · 5 replies
I was wondering if anyone had ever implemented a plasma gun in Torque. By this I mean a gun that fires a constant stream until the player releases the fire key. The beam image would be (at least in part) done with particles, I am assuming? If anyone has an idea how I might approach this, that would be great!
#2
05/28/2005 (1:50 am)
How's about a bit of example code to illustrate Mr. Lund's suggestion :)// In ~/client/scripts/default.bind.cs:
function SomeBinding( %val )
{
if ( %val ) // key pressed (signal to start)
{
// ... do something interesting ...
// schedule another call to this function, this is
// our recursiveness which allows for the whole
// "hold key down repeats action"
$SomeBindingID = schedule( 50, 0, SomeBinding, 1 );
}
else // Key released (signal to stop)
{
// cancel our last scheduled action to stop the
// recursive calls.
cancel( $SomeBindingID );
}
}
#3
05/28/2005 (6:48 am)
Yeah, that makes some sense. Thanks, guys! I assume I'm at least partially correct about the graphical part of it? using particles, i mean.
#4
Ok, I found them. The new google search on GG is really nice. :)
Eric Risser's Laser
Torque Laser Beam resource
Now, I haven't tried either of these yet, so I can't say for sure if this is what you are looking for. But they might be worth checking out.
I hope you get it working!
05/28/2005 (7:57 am)
A while back someone implemented a laser beam, similiar to what you are talking about.Ok, I found them. The new google search on GG is really nice. :)
Eric Risser's Laser
Torque Laser Beam resource
Now, I haven't tried either of these yet, so I can't say for sure if this is what you are looking for. But they might be worth checking out.
I hope you get it working!
#5
05/28/2005 (9:03 am)
Oh! Thanks Drew! I had implemented the "Torque Laser Beam Resource" before, and it was not exactly what I wanted. Eric's, however, looks perfect. How the heck did I miss that?
Torque Owner Thomas \"Man of Ice\" Lund
But you can do it in script basically.
In your key map you start a schedule on the key down - one that every X milliseconds fires the gun you hold in the hand. On the key up you cancel that schedule.
You might want to optimize that, so that the schedule sits on the server side, and your key map code just sends a "startFiring/stopFiring" on up/down - instead of spamming the server with fire commands.
Shouldnt be too hard to implement