Weapon Switching in the FPS Demo
by JD · in Torque 3D Beginner · 07/14/2013 (3:14 am) · 6 replies
so I found this: http://docs.garagegames.com/torque-3d/official/content/documentation/Introduction/NewFeatures.html
it indicates that weapon toggling/switching/cycling is already ready....
how the heck do I map this to a key? If this method works...
it indicates that weapon toggling/switching/cycling is already ready....
how the heck do I map this to a key? If this method works...
About the author
Check out my website: http://lethonline.com/ *a home for all gamers!*
#2
I know how to bind them to the keys... but the keyboard doesn't go up to 11 (it possibly should?)
I guess what I'm asking... to clarify anyhow... that new feature list indicates that there is some sort of array or w/e to be built where you can add multiple weapons
This was the evidence... not to mention it made references in several locations....
%player.addToWeaponCycle(Lurker);
so if weapon cycling is enabled already what is the movemap to map a key to the weapon cycle system?
07/14/2013 (7:01 am)
ok, but I'm adding 11 weapons with the possibility of more.I know how to bind them to the keys... but the keyboard doesn't go up to 11 (it possibly should?)
I guess what I'm asking... to clarify anyhow... that new feature list indicates that there is some sort of array or w/e to be built where you can add multiple weapons
This was the evidence... not to mention it made references in several locations....
%player.addToWeaponCycle(Lurker);
so if weapon cycling is enabled already what is the movemap to map a key to the weapon cycle system?
#3
Also note that the hotkey setup described by Lukas is not the same as the weapon cycling method. Using addToWeaponCycle() will add the weapon to an array in the order in which the calls are implemented.
The "hotkey" method simply makes a direct call to the use() method which will then use and equip the indicated weapon/item.
07/14/2013 (12:10 pm)
Quote:
so if weapon cycling is enabled already what is the movemap to map a key to the weapon cycle system?
function nextWeapon(%val)
{
if (%val)
commandToServer('cycleWeapon', "next");
}
function prevWeapon(%val)
{
if (%val)
commandToServer('cycleWeapon', "prev");
}
function mouseWheelWeaponCycle(%val)
{
if (%val < 0)
commandToServer('cycleWeapon', "next");
else if (%val > 0)
commandToServer('cycleWeapon', "prev");
}
moveMap.bind(keyboard, q, nextWeapon);
moveMap.bind(keyboard, "ctrl q", prevWeapon);
moveMap.bind(mouse, "zaxis", mouseWheelWeaponCycle); Also note that the hotkey setup described by Lukas is not the same as the weapon cycling method. Using addToWeaponCycle() will add the weapon to an array in the order in which the calls are implemented.
The "hotkey" method simply makes a direct call to the use() method which will then use and equip the indicated weapon/item.
moveMap.bindCmd(keyboard, "1", "commandToServer('use',\"ItemName\");", "");. If you need more than 10 hotkeys you'll have to use a modifier key (ALT, CTRL, SHIFT) in combination with the relevant number key... alternatively: I think that Steve Acaster has posted a Resource that simulates HalfLife2 style weapon selection by doubling up the 0-9 keys so that they toggle between 2 separate weapons each.
#4
essentially I had two problems from the initial tutorial I was using.
I didn't know where to put these:
$RemapName[$RemapCount] = "Previous Weapon";
$RemapCmd[$RemapCount] = "prevWeapon";
$RemapCount++;
$RemapName[$RemapCount] = "Next Weapon";
$RemapCmd[$RemapCount] = "nextWeapon";
$RemapCount++;
They now reside in default.bind.cs
Needed to add this in game.cs:
%player.addToWeaponCycle(GrenadeLauncher);
plus all the other weapons-per class.
07/14/2013 (1:47 pm)
Hi Michael, thanks for the in depth answer, I apologize for not getting back sooner today but I've been hopped up on meds and extremely busy game devving... I hopped on the IRC Channel for and asked a gentleman named Tim-MGT... he helped me out...essentially I had two problems from the initial tutorial I was using.
I didn't know where to put these:
$RemapName[$RemapCount] = "Previous Weapon";
$RemapCmd[$RemapCount] = "prevWeapon";
$RemapCount++;
$RemapName[$RemapCount] = "Next Weapon";
$RemapCmd[$RemapCount] = "nextWeapon";
$RemapCount++;
They now reside in default.bind.cs
Needed to add this in game.cs:
%player.addToWeaponCycle(GrenadeLauncher);
plus all the other weapons-per class.
#5
07/14/2013 (10:23 pm)
The rest of that stuff (for mapping to the options dialog) is in core/scripts/gui/optionsDlg.cs, towards the middle of the file.
#6
07/15/2013 (2:57 pm)
Ok, Thank you Richard.
Torque Owner Lukas Joergensen
WinterLeaf Entertainment