0 votes

hi all,

i'm trying to implement a reversal kick. however when i press the attack button, the character continues to do the action and never stops. see example gif:

https://giphy.com/gifs/VzaDEAnTyrAAYjGDjw.

here is the paste bin. note particular line involved which is 23 to 27:

https://pastebin.com/uXSUZeDS

any help would be greatly appreciated

Godot version v3.4.4 stable.official(419e713a2)
in Engine by (48 points)

1 Answer

+1 vote

First of all your code has quite a bit too many bad practice stuff going on. Too many if statements on the one hand and badly named variables on the other. To give an example, we have the source of your problem! You have 2 variables, attacking and isAttacking, which both mean the same thing, and you are setting the fist one to true when pressing the kick, and checking for the second one. Thats why it doesnt work as intended. Stick to one way of naming stuff to avoid these issues (for example, if you stick with "isdoingstuff" also change your jump to is_jumping). I also recomend reading up on setting up a state machine, since it will make adding more stuff easier on the future!

by (418 points)

yes your right. i did start looking at state machines and it does have a much more cleaner and efficient approach . i appreciate the feedback thank you

In physicsprocess () and apply_movement () you are performing a jump == false when it should be jump = false (one = character). The former is a boolean comparison and the latter is an assignment, that might be causing issues!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.