Move with left thumbstick and rotate while I attack?

Sorry in advanced if this is a simple/silly question, I’m new to game development. Basically what I am trying to accomplish is: left stick controls direction and rotation of character, when I attack I cannot move but can still rotate.

I’ve been able to accomplish this if “Orient Rotation to Movement” is unchecked, but then my character only faces one direction, and I can only rotate if I’m attacking. If I leave “Orient Rotation to Movement” checked, the left stick will control movement and rotation, but then my character won’t rotate while attacking.

Here’s the BP:

Am I going about this wrong, or am I missing something? Any help would be greatly appreciated!

Hey there @RiverDragonheart! Welcome to the community! There are no silly questions here, everyone here is learning every single day, including myself. I like that you used the Gate node, I rarely see new users touch it!

But also, this may not be best practices, but since you could change your orient rotation to movement off while attacking, then on when done, wouldn’t it accomplish what you’re looking for?

There’s a million ways to go about moving and attacking, so it’s not wrong, but it’s a bit different than other implementations.

1 Like

Thank you kindly for the welcoming, and help! That solved it, I didn’t know you could toggle Orient Rotation like that. The only issue now is when I attack the character will turn to its right x)

Yep, now you’re going to have to set the rotation to the rotation of your input and apply that to your character. You can use this node even if you’ve got orient movement on
image

if you want to set it once, that’s a good plan, if you want to set it repeatedly that would require running that on until the attack is done, which you could use event tick for if you’d like!

May I ask how I set the above node? I tried plugging it in before my rotation inputs (Add Controller Yaw/Pitch) and tried after. For new rotation I tried “Get Player Rotation” with “Break Rotator” and “Make Rotator” piping in the Z (yaw) but still I rotate to a random direction, usually to the right, when I press the attack button.

Sorry about that, for some reason the notification missed me here. A simpler option would be to have a Boolean for IsAttacking? and if true, set the walk speed to 0, then when not attacking set it back to whatever the original value was. This way you don’t have to use a rotator and it doesn’t mess with the logic of your character movement.

Wrote up a quick and mess example, AttackStopMovementButKeepRotating posted by anonymous | blueprintUE | PasteBin For Unreal Engine

1 Like

Thank you, I appreciate you mocking up an example! At first it still had the issue of setting the char rotation to forward Y, after some experimenting I found the cause. The toggle of “Orient Rotation to Movement” to false when I attack would cause the rotation issue.

I can’t thank you enough, the blueprint above was exactly what I needed.

No problem, sorry it was such a mess of a blueprint! I slapped it together rather quickly. You could definitely optimize it a bit, but the idea is there!

1 Like