Grenade Throwing
by Chris "C2" Byars · in Torque Game Engine · 09/14/2005 (3:17 pm) · 8 replies
Let's see here. I would like to use projectiles for my grenade object.
I need to make it so when the player right clicks, it will toss (fire) the grenade projectile, at any time, as long as you have grenades. I need to find out how to fire a projectile using ammo, but without requiring a weapon that uses that ammo to be selected or even in existance.
How would this be done?
I need to make it so when the player right clicks, it will toss (fire) the grenade projectile, at any time, as long as you have grenades. I need to find out how to fire a projectile using ammo, but without requiring a weapon that uses that ammo to be selected or even in existance.
How would this be done?
#2
09/14/2005 (4:11 pm)
This is seriously trivial. All you have to do is use the built in, scripted inventory system for your ammo. Then in the Player::ontrigger method, spawn your grenade and take away some ammo if the alt trigger is pressed.
#3
@Moore: Well.. yeah. But, how would I make it act like a projectile and be able to link it to ammo objects and all that?
09/14/2005 (4:28 pm)
@Treb: Sure, thanks. :)@Moore: Well.. yeah. But, how would I make it act like a projectile and be able to link it to ammo objects and all that?
#4
09/14/2005 (4:41 pm)
Well, like I said, you spawn it. Have you looked at how the Crossbow works? In the onFire method, it spawns the projectile defined in the weapon image datablock. For the ammo, just use the built in inventory system. But don't forget to add your grenades to the maxInv list in your player datablock.
#5
09/14/2005 (4:43 pm)
Ah..*shakes head*..I got it. Thanks. :P
#6
In default.binds.cs client side I have the mouse2 (or mouse1) button which is the right click, bound to "throwGrenade".
I'm not sure where to go from there, how to get the throwGrenade command to spawn the projectile and launch it forward when your right click, or even if I modified my weapon script correctly to test out a grenade.
09/14/2005 (5:34 pm)
Well, here's my server/scripts/grenade.cs file.In default.binds.cs client side I have the mouse2 (or mouse1) button which is the right click, bound to "throwGrenade".
I'm not sure where to go from there, how to get the throwGrenade command to spawn the projectile and launch it forward when your right click, or even if I modified my weapon script correctly to test out a grenade.
#7
09/14/2005 (5:44 pm)
Cool, do you mind if I use that?
#8
09/14/2005 (5:58 pm)
Not at all, but it's nothing but a stripped down version of my XM8 weapon. I just need to work a way to set up the "grenadeThrow" command and make it fire the "grenadeProjectile" if there is ammo.
Torque Owner Dracola