How can I make pawn rotate exactly 90 degrees on Y axis with one button press?

I am making a top down game. I have rotation control of the possessed pawn mapped so that you use Q and E to rotate on the Y axis. I need to make it so the pawn ( which is box shaped ) rotates left or right just to the point where the next face of the mesh faces upwards then stops, for each time the buttons ( Q or E ) are pressed and released.

Couldn’t you use Set Actor Rotation node?

To rotate exactly 90 degrees, you could eitehr add 90 degrees to current rotation using the ‘Combine Rotator’ + ‘Make Rot’ nodes, and then feeding it as the new Rotation.

To transition smoothly, use a Lerp node

I’m not sure about this, but I think I saw a node named ‘Set Delta rotation’ or ‘Set rotation offset’ somewhere in the blueprint. Perhaps those will do this for you.

Ok, the way I had it before was ‘InputAxis Roll’ with ‘Axis Value’ going into ‘Make Rot’ (hooked into roll) and the ‘Input Axis’ plugged into execute ‘AddActor Local Rotation’, with ‘Make Rot’ plugged into the delta Rotation. I see the ‘Set Actor Rotation’ node you are talking about, but where do I hook it up at?

Thanks for the response by the way.

IF you always want to rotate 90 degrees, why worry about axis values? You only need to consider the sign (to decide whether to rotate clockwise or counter-clockwise)

Set Rotation is a node that is available in the blueprint. Simply start typing it and you will get it. Put self as the target (default). The new rotation calculated by adding (or subtracting) 90 degrees should be the input. To transition smoothly, you can use a Lerp node and feed its output to the Set Rotation node.

If you still cann’t get it right, I will try to create a blueprint myself and put it here (will take 10 hours though - I not at my place right now)

Sorry in advance for being such a noob, I’m pretty much just starting out learning this. I had it set up to that the mesh rotates to the left when Q is pressed and to the right when E is pressed. Using the InputAxis Roll was the only way I knew how to do that. Yeah if you could show me an example that would be Awesome.

Ok I have setup a demo.

Demo video: [Rotating cube demo][1]

Blueprint component setup (notice that spring arm rotation is absolute)

Blueprint Event graph

I have mapped ‘E’ to ‘RotateClockwise’ and ‘Q’ to ‘RotateCounterClockwise’ (both are Action mappings)

Awesome! Thanks, I had figured out a way to do it. But the way I did it myself it rotated instantly, I actually wanted to be able to see the transition being made like in your demo. I’m gonna implement this asap.

One more question though. What is the node that is in between ‘Get Actor Rotation’ and the ‘Branch’ Node?

Thats a ‘Not Equals (rotator)’ node.

If your issues is solved, dont forget to mark the thread as ‘Solved’

Can someone explain how to set it for the character?

Hello

I am also interested in how to make this work on the players actor. I have been trying to set up a system where the player actor only turns 90 degrees left or right. I am using the starter content and have followed the endless runner video tutorial for some of the code that I needed. the 90 degrees turn kind of works. the problem is when the player holds the key down it becomes a 45 degree run.

here is the relevant blue print code:

so if anyone can help with this it would be greatly appreciated.

it’s called “not equal to” , when A is not B it returns true :slight_smile:

Can i assign that to my player?

Thanks mate. I was looking for it a long time.