Hey, so i found a bunch of tutorials and videos on how to make a dash/sprint by changing the max walk speed when pressing a key. However, thats not what im trying to do.
What i wanted to do is basically a independent/“infinite” dash, where while you press a key(specifically the mouse key) all other movement controls(wasd) are disabled. So you hold the button and go in the direction your facing in high velocity. When you release, you stop and go back to normal.
If anyone knows a way to make this happen, please help. Thank you all in advance!
You could use a boolean to block regular movement code paths while dashing, and emulate as if user was pressing only forward.
Something like this :
This is better if you only want to block some movement capabilities (eg. wasd) while still allowing some other ones.
Alternatively if you want to really block all of them, a simpler solution is to simply ignore movement inputs temporarily. Tick bForce in the AddMovementInput node for sprinting, so it becomes the only one that is not ignored :
Alternatively, depending on the type of dash you want ot have, you can set up a custom movement mode to handle it. Similarly to how “Flying” and “Swimming” differ from “Walking”, your custom movement mode would implement movement in its own way. But that is a more complex topic. This thread has a bunch of links you may want to look into.