Different attacks reusing the same button

I have really fun with this program, have everything set up for simple platform-hack´n slash with my health and enemy health. One button for weak attack and one for strong.
And while was having my sweet time i decided, i want more attack moves but hate having alots of buttons.

So tried set so button one does nothing but holding the and pressing directional key, up, down, left and right would give 4 moves with just one button… sort of like the game Barbarian.

Holding button - no action
press up - attack animation
And at WORKED!!
But then i tried assign holding button and press left key. And that dident work because left key is aleady assign to walk lelt. the press left key even turns red in event window.
And i am not finding any way around it.

Quite disappointing as gdevelop on all other fronts are wonderful and easy, even for a major dork as me.

This might need variables to work if you want to use the same keys for different things.

I recently set my game up to shoot two different weapons with the same keys (the change is not published yet) and used global variables to do it so that the selection can remain across scenes.

It would be interesting to see your example.
In my case I made a Weapon Selector.
With the jostict usb and the Selector of weapons occupy the directional arrows … and the analogues for the movement of the player.

Well, should see your events but I think GDevelop do exactly what you told it to do.
For example you probably do something like:
Left is pressed : do this
Left is pressed and Ctrl is pressed : do something else

If that’s the case, how your program supposed to know you want the first event to be ignored when the second event is true?
Solution is very simple, check also if the second key is NOT pressed then execute the first event…

Left is pressed and Ctrl is NOT pressed : do this
Left is pressed and Ctrl is pressed: do something else

Ah, it’s not really for an example :wink:
It’s part of my game, or will be the next time I publish an update.
I didn’t get the events from any example either.

I created two global variables (as a structure), which goes like:

  • weapons
    ** bandaids
    ** gauze

If band-aids and gauze = 0, player will shoot band-aids
If band-aids and gauze = 1, player will shoot gauze

Band-aids are active by default and you can switch to gauze by pressing “G” (this condition sets both of the above variables to = 1). If you have switched to gauze, then you press “B” to shoot band-aids again (“B” will reset the variables to 0). I have this all set up so that players can use 2, 4, 6, 8 on the number pad for shooting.

Maybe that’s a convoluted way of doing it and there is more to it than what I put above, which is more specific to my game, but it works. :slight_smile:

1 Like

I understand your point.

Many methods for the same result.:+1:

1 Like

gamepad… good idea!
still i really wanted to make it a one button game but try gamepad for now then

You can use timers to determine the last time the button was pressed and creat a condition inverted on that timer

ddabrahim please tell me more:

is it possible to get an simple fomula to change animation from walk to run
with a button?

This is how i make my char run. you can do it without movementstates, and use when speed is greater then walking speed do = run animation

nah… i give up. making games is not for me

The big problem will be to take a gun and exchange it for another.

if you walk with each different weapon you would have to create a different animation for the 8 directions.

If your game will have only one type of weapon as a sword, there is no problem. but if you exchange between several weapons it is more complicated.

if you do not want to complicate your life you can do only the attack animations for each weapon.

4 animation states, 1 handed, 2 handed, spear and bow. still alot, but manageble.
well, + run/sneak/jump attacks for each of them too :stuck_out_tongue:
a 7 Years project.

Well, these things take time. long time. you have to have perceverance. :relieved::+1: