im working on a game where i want the characters to switch between a melee weapon and gun by pressing a button or key. is this possible?
im working on a game where i want the characters to switch between a melee weapon and gun by pressing a button or key. is this possible?


Hm... perhaps use alterable values
Eg.
Key pressed -> add one to value
Value = x -> Change weapon to _______ //where x is an increasing value
Value > = m -> set value to 0 //where m is the number of weapons you want, so this event cycles it back to the beginning
thanks! i'll give that a shot. something else i forgot to add to the question: for the weapon switch i will have separate animations eg. idle walking running etc. would it be easier to possibly make another active object and then somehow link the 2 with a specific key press? thanks again for the tip :grin:
i may be on to something here. i've tried creating 2 active objects, one for melee, one for the gun and it seems that if i run this event:
"Upon pressing "C" - "Create", "Create Object" - "active weapon", then run "destroy" on my previous active, then that works. im getting ready to try to see if i cant do the opposite and possibly switch between the 2
Awesome! not EXACTLY what i wanted but it works! lol i just assigned and equip button and unequip button. now to test and see if i can assign specific animations between the 2
new can of worms! lol i can make the animation change to run when i press left or right but he doesnt move.


Hm, did you check to see if the animation running loops and all that? And did you try restoring animation speed when you change the animation?
Or is the player not moving but the animation is working?
well there are a few things going on man. i was able to make the animations change depending on the key press like it usually does but the active object doesnt move. im using a sensor object to link my sprites to and i noticed that there wasnt anything that linked my new sprite to the sensor object. now im trying to figure out how to make that work right. its a little on the bug-ish side that way. you can press the key to equip and have an army of gunmen! lol it just clones the idle stance


Uh I don't know what's going on. Maybe somebody else could give it a try?
-Upon pressing SPACEBAR toggle internal flag 0Originally Posted by Warmachine
-If internal flag 0 is on > Set weapon to melee
-If internal flag 0 is off > Set weapon to gun
This technique will work for a one-button switch between weapons. If you want you can do it this way, it's up to you. Also note that the "internal flag" comes from an active object. Good luck!
-Variant