Attack help
raze_struck
Member, PRO Posts: 141
i've been desperately trying to figure this out, basically I have an attack button, I want to make it so that when the player presses the button the actor will attack, but can't attack for 0.5sec afterwards. Also I don't want the player to be able to hold down the button and freeze the attack, or spam the button and keep messing with the boolean.
I have tried so many ways and yet I can't get this down.
Tried declaring a self boolean in the attk button and saying;
IF actor receives press
change attribute : selfpressed to true
otherwise : self.pressed to false
IF self.pressed is true
change game.attk to true
after 0.5 sec change game.attk to false
This takes care of everything, except for the spamming of the button !
Comments
not to be rude, but your basically starting rom nothing. look at some of the free templates out there, most o them answer this question.
This will work as long as you include If game.attk is false as a condition and set it to if ALL conditions are true:
IF self.pressed is true AND game.attk is false change game.attk to true after 0.5 sec change game.attk to false
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I know I'm not going crazy, I did what you said, and even now when i hold down the mouse button on the attack, it keeps constantly changing it to true.
opps wrong screen shot
refer to this one please ;
It doesn't make sense, refer to the above and tell me where i went wrong. I managed to create an entire inventory system, a level up system, a teleport system, double jump, dash, everything is fine, just when I attack, I can keep spamming the button and changing it to true
@raze_struck Looking at that logic, my guess would be because of the ordering of logic and the way the rules are set; the game.basicattack to true is causing the issue (making the rule no longer valid before it has time to finish). Try wrapping the Change game.basicattack in a timer of after 0 second run to completion.
If that doesn't work for you try this:
**_Rule:
When touch is pressed
Attribute game.basicattack is false
timer: After 0 seconds run to comlpetion:
Change game.basicattack to true
Rule:
When Attribute game.basicattack is true
timer: After .5 seconds run to comlpetion:
Change game.basicattack to false_**
If you want to you can also adjsut the 0 second timer to .1 or w/e feels right for gaps between attacks when someone is trying to spam. Let me know if you get stuck, i've had to implement this in a game with some crazy rules, so I know of another way to do it too.
thank you soo god damn much !!!!