x


FPS main and side weapon question

I have an equip script, that equips weapons based on what game object you click on. Weapons have a "class" with different parameters such as damage, max ammo... etc. I'm using an boolean to see if its active and I need to know how to "switch from main gun to a sidearm." IE, user presses 1, and the main gun that is equipped becomes active, and when the user presses 2, the sidearm becomes active and the main gun becomes inactive. Any ideas?

more ▼

asked Apr 11 '12 at 10:26 AM

22andrew22 gravatar image

22andrew22
1 1 1

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
if(Input.GetButtonDown("1") //"1" is the name you put in Edit->Project Settings->Input
{
    if(!Primary.IsActive)
    {
        Primary.IsActive = true;
        Current.IsActive = false;
    }
}
else if(Input.GetButtonDown("2")
{
    if(!Secondary.IsActive)
    {
        Secondary.IsActive = true;
        Current.IsActive = false;
    }
}
more ▼

answered Apr 11 '12 at 12:07 PM

NickWalker12 gravatar image

NickWalker12
122 3 6 9

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3459
x1172
x237
x16

asked: Apr 11 '12 at 10:26 AM

Seen: 328 times

Last Updated: Apr 11 '12 at 12:07 PM