How to lock player movement whilst boolean is true?

So I’ve done a lot of searching on Google and YouTube because there appears to be many solutions to this type of question, but so far nothing I’ve tried works. I’m still very new to Unreal so I might be overlooking something basic - if you suggest an answer, please be as thorough as possible as I’m still a beginner!

I’m making a third-person demo and I’ve added a function to the Third Person Character BP that allows a charged attack when the right mouse button is pressed down. When the button is down, the Boolean ‘Charging?’ is set to true, and then the damage variable increases over time. An animation montage also plays (one animation for ‘charging’ and another animation for ‘firing’ once the mouse button is released).

My problem is that whilst the right mouse button is held down (which can be for an indefinite amount of time as the damage increases with time), the charging animation plays, but the player can still move the character by pressing W etc. So the character is effectively sliding across the floor whilst this stationary pose animation is in progress, and it looks very dumb.

I’ll include all the code for the charging attack, and then two attempts I’ve tried to disable character movement. I have no idea why it’s not working because these are the two solutions suggested by most forums/videos.

And the fixes I’ve tried:

I’ve also tried with a branch node, but still no luck:

Thanks for any help!

1 Like

Have you tried calling “Disable Movement” before playing the montage?

1 Like

I hadn’t, and that did clean up a lot of the inefficient attempts I was trying, so thank you. The only problem was that after ‘disable movement’ is called (on mouse click), there is no ‘enable movement’ to call when the mouse button is released. But I tried using ‘set movement mode’ (set to Walking) for the ‘released’ path and it works! Such a simple solution, not sure why using a boolean & branch to check if the montage was playing didn’t work, but thanks so much!

2 Likes