What the code below does is adding FallingLateralFriction when one of the WASD keys is released, but what I need is to add FallingLateralFriction when none of the WASD keys are pressed at the same time - so I need it to detect if any of the WASD keys are being inputed, if not, add FallingLateralFriction.
Interesting problem you have here.
Here is an idea:
- Create a Boolean Variable for each key input and set it as true or false depending on whether or not it has been released.
- Then, off of Event Tick, create a branch that where it takes an OR operator and you input each of the Boolean Variables for the key inputs. That way if one of the Key Inputs is true, the branch will go true. If all are false, the branch will go false.
- Hook up your Lateral Friction Falling Code
- (Optional) On Event Begin play, Use a Set Tick Interval node and the value at .1 (1/10th of a second). That should help optimize the tick function if you’re worried about it running every frame.
I hope this helps and let me know if this makes sense!
Hey, thanks for the reply. Do you mean something like this?
I can’t reproduce anything with this, guess I’m doing something wrong - however, I found a workaround but still it isn’t perfect:
I think the main problem is the Released state because it only reads it if there were a previous Pressed state
Not quite! It doesn’t look like the values are ever set to true so it will always trigger false. Also try to use positives as your Boolean values. Having it as Not Pressed is confusing (at least to me :))
Lets do W for an example:
Create a Boolean variable called W Pressed.
From the W Event, Set the W is Pressed Variable to True off the Pressed Execution Pin. Then set the W is Press Variable to false off the Released Execution Pin.
I think you’ll want to use Get Variables rather than pulling the Pins directly from the Set Variables as well.
I’ll try to throw this into an example BP when I get home tonight so its a bit more clear.
Hi, I’ve done it like this:
Is there a way to print it like this? Why can’t I use one duplicate event that is already declared in other code, like “Event OnLanded” or “Event BeginPlay”?