How Do You Use Booleans to Map Two Buttons to a Single Action?
I'm attempting to map two buttons to one action multiple times such as dashing in multiple directions.
Left, Right, and Up with Down being the default for the Dash Button by itself.
So, I would need two button presses to dash left = Dash + Left
And so on.
I've been reading about how to do this and one explanation was to use booleans, but I have no idea how that works visually. I'm also a real beginner at this, so any help would be appreciated and explain with pictures if that isn't too much trouble? Or at least in a comprehensive manner.
asked Oct 16 '18 at 12:02 PM in Blueprint Scripting
Sorry no pictures since I'm at work, away from my fun Unreal station.
Boolean is just true/false, on/off. So the idea is that one input action will set a boolean you create, called isDashing for example, to true (checked checkbox), and then releasing that button will set it to false (unchecked checkbox).
Then in your OTHER input actions then you have your normal movement, but at the very beginning you can split that off into doing the dash action instead by running the white wire through a Branch node with the isDashing boolean (red variable node) plugged into it, and making the False branch wire go to your usual motions, but the TRUE wire goes to your Dash motion code.
Doing it that way, it's kind of like holding the Shift key to make it so hitting letters on the keyboard types upper case instead of lower case. But with your project it's holding the Dash button (whatever that is) so that hitting directions on the keyboard will Dash instead of moving normally. Then when the button is released, then the boolean is set to false and that branch goes down the False path and does the normal movement instead.
So that's two separate graphs on your same blueprint: One for setting and clearing Dash mode (which only needs the Dash key's Input Action Event), and one where it chooses whether to do dash movement or regular movement based on if Dash mode is on (which you already have the Input Axis or Action event(s) in place for the arrow keys, just need to branch it off to act different for dash mode).
answered Oct 26 '18 at 07:47 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here