Gun Change System

Hey guys!
First of all, if this seems familiar, it is. I seriously can’t seem to get this one down…despite posting about it already (but that post wasn’t EXACTLY like this one; that was a gun pickup system)

I want to know any method at all for 3 or 3+ gun changes

Of course, adding in changing animations and reload must be able to be added
I have added a one gun and two gun system…I don’t know why I created them…but here they are :slight_smile:
OneGun.blend (248 KB)
TwoGun.blend (249 KB)
Anything that works will do. Thanks :slight_smile:

ok,

you need to have a value, set by pressing a button,

then, use logic, or python, to remove the old gun, and add the new gun

the more flexible it is, the more python you will need,

keypress 1----------and------------Gun=1

if Gun changed-----------and-------------message kill Gun (remove old gun)
________________________--------------property Switch=1

if Switch=1------
if Gun=1---------and-------------add gun

the only problem is this method will not keep ammo in the gun

here is my manager again, with some logic and python removed that was old/not working

Note I added a system to disable the weapons if you are carrying something in my own game,

so uncheck holding (set to False)

Cheers

Attachments

WeaponManagerBeta2 (Z).blend (799 KB)

so uncheck holding (set to False)

Uncheck holding on the weapon manager]

I added this for wrectified, so one cant pull a gun while carrying,

Oh and I’m using Blender 2.69…maybe there are some code changes?

Ahh I see…Will try renaming bricks and objects to make more sense to me

Q= pick up

0- remove weapon equipped

up and down = cycle weapons

Mouse1 =fire

R=reload

No code changes. The error was caused because you’re trying to divide something by 0. Which probably means that you haven’t defined your properties properly, and your script is treating the variable as 0.

What I like to do for the gun system is this. Have four (or “however many guns you have/want + 1”) properties. Three (or however many) properties for the guns, and have one be for “Holding”.
Put whichever weapon slot should be active into the "Holding’ property.
When your player picks up a gun, have a script check through the different gun properties. If one’s empty, set that property as the gun you picked up.
When you switch guns, have a system that checks the “Holding” property to see which slot is active, then change it to whichever slot comes next. For example: "if object[‘Holding’] == “slot1”: (then) object[‘Holding’] = “slot2"”
Finally, have a system that sets your player’s gun based on what the “Holding” property is.

Yeah I got it. Just needed to tinker with it…Got the blend file working also :slight_smile:
making changes to the naming and re-doing the shooting system to make it more realistic…will probably be done an hour or two

Oh, and I think your system is great, except it may be a little unrealistic. Guns usually contain different clips, so if I have 2 guns with the same ammo, what if I want them to so different damage, or shoot at different rates? The point is, I think having 100 lazers for all your guns isn’t a good choice, instead make each gun have different clip capacity. For example: gun1 has 50, gun2 has 30, gun3 has 20 bullets, and they can’t share them…But that’s just a suggestion :stuck_out_tongue:

I also realized that if I have a gun, I can’t pick up another one unless I don’t hold anything. maybe if I have a gun and pickup a gun, it automatically switches to that picked up gun?

Did a little bit or renaming with it, changed it so that there are no extra logic bricks in the “Player” cube…Up until now, everything worked out fine, I changed the positions of the weapons on layer 2, and I don’t know why I pickup all 3 and I cycle through the 2nd,1st, then third weapon…So I pickup all the boxes, hit up arrow, and the 2nd wep shows up…why?WeaponManagerBeta2 (Z).blend (902 KB)

Nevermind, here’s the revamp found out I changed the keys XD
WeaponManagerBeta2 (Z).blend (902 KB)

What does

G['Init']=1

mean in line 26 of PickUpGun?
Where is the animation and why is there a useless animation for all the guns?

I want to try changing the guns to more graphical looking (but still low poly) ones
and make an arm animation, parenting the gun to the right/left arm, but I don’t know where the animation and how the parenting works in the code :confused:

init in the gun is what makes it rise,

you can eliminate this in each gun, it’ the logic on top, (guns on layer 2)

also, that code was used, when the system was only designed to carry and drop 1 weapon,

(initially everything was on layer 1)

Ahh, ok I see now…Great system, although I’ll probably have to modify it to suit me…thanks :slight_smile:
I’m guessing the blend is finished?