How can I make the main character duck?


#1

Hi how can I make the main character duck while the down button is pressed?? BTW if there is a thread to this question send it


How to make a platformer beat em up
#2

Add an animation to your character sprite where they are ducking. Then add an event where when the down button is pressed the sprite changes to that animation.


#3

So I did it but it won’t work.


#4


#5

Add a Trigger once while true to the down key check condition. Otherwise you’re setting the animation to 3 every single frame that the key is held down.


#6

This is how I have mine set up. Works for me. Hopefully it can help. My “squatting” animation is only one frame, though.


#7

You’ll have the same problem as Ery if you have more than one frame in your squat animation.

How many frames are there in your other animations?


#8

I’m not having a problem lol. Mine works, so I was posting my code to try and help him out.


#9

Yes, I know you’re not having a problem. That wasn’t what I was getting at.

You only have one animation frame, so your change to the squatting animation is not bringing the same error that Ery has. If you add an frame to your squatting animation, you will have the same issue Ery has. As per my previous post.

Ery needs to use the Trigger Once condition when checking for down key press, because otherwise the condition is true while the key is pressed, and the animation is reset. Every time the screen is refresehed/updated. Which is about 60 times per second.


#10

Thanks it worked!! The only thing I needed to change was that the animation I just change it to one frame.


#11

You missed @MrMen’s point:
Just add the “Trigger Once” advanced condition to the “Down key is pressed” condition when you set the animation. Otherwise the animation will restart each time “Down key is pressed” is evaluated… which is every frame.


#12

Like this? Because it doesn’t work. BTW I’m new :grin:


#13

No. Not there. Click on the “Add condition” immediately below the “Down key is pressed” condition and add it there, so the two are in the same box:


#14

Ok so I did it but how can I make the character move with a different animation, to either side if the down and left or right button is pressed.


#15

When you check if the left or right keys are pressed, have a subevent that checks whether the down key is pressed.