Game Development Community

Taking weapons Halo-style?

by Daniel Buckmaster · in Torque Game Engine · 02/12/2007 (9:43 am) · 8 replies

What would be the best way to do this? If you haven't played Halo, basically, when you get near a weapon, you get a little text at the top of your HUD that tells you to press a button to pick it up. The message goes away when you move out of your pickup range.
I assume that a container search every tick would be the best idea, but does that entail a performance drop?

About the author

Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!


#1
02/12/2007 (10:26 am)
Why not surround the weapon with a trigger and size appropriately then add the functioniity to the trigger script?

Regards

Graham
#2
02/12/2007 (10:34 am)
Triggers check their box every tick.
Edit: Or well, they don't. The player checks for triggers on each move, rather.

I think in stock TGE the player is already checking its area for items. You just need to add the GUI.
#3
02/12/2007 (10:52 am)
Stefan's got it. . .

Look at how health and ammo is done in starter.fps. Copy that approach, but instead of adding the ammo, you simply pop up a GUI and provide a moveMap action for picking up and switching weapons.
#4
02/16/2007 (8:29 am)
Can I then have each weapon object create its own trigger area? And somehow nullify it when the weapon is picked up, too (actually, it'd be cool to be able to go up and grab weapons people are already carrying ;)).
#5
08/23/2009 (5:27 am)
The starter fps uses an oncollision to pickup or make the gui show up. While that may work, how do you get the gui to disappear if you dont pick up the weapon? Ive been trying to think of a way that works, and i havent yet found one. I may be missing something really simple here, but the gui stays on when i walk away..
#6
08/23/2009 (5:44 am)
Well, onCollision is only called once, when you first collide with the object. There's no way to make an 'onUnCollision' callback. I'd suggest you don't use collisions for this, or just put the GUI on a timer after the collision.

Just to note, I've abandoned this concept, and I'm now planning to handle weapon-grabbing RPG style, by looking at them.
#7
08/23/2009 (5:46 am)
@Drew:
just (schedule) set a timer to toggle the GUI off.
#8
08/25/2009 (3:43 am)
@michael:
Thanks boss! it works now!

All i need to do now is to figure out how to stop it flickering on and off, but this is still a step in the right direction.

mebbe ill put an evaluation in the function that turns it off that checks if the oncollision is still true.

hrm.. how to word this..