I’m using UE 5.1 and have created a tank pawn that will be used as my main player pawn. I’m trying to rotate only the “TankBarrel” 180 degrees when the “A” key is pressed and then 180 degrees in the opposite direction when “D” is pressed. It needs to be a smooth sweep from its current orientation to the opposite side. “Add Controller pitch Input” would be great if it just rotated the barrel but it rotates the whole tank, camera included lol. The game is going to be akin to an old ms-dos look so the tank barrel need only rotate on the “Y” axis
You can try something like ‘add relative rotation’ on the barrel, and clamp it between the values you want. So, add the action value to the rotation.
Ok so that works, thank you! I was trying everything i could think of to make this work cept what you suggested lol. Thank you so very much for your time, I know this seems like such a simple question to ask but I was stumped and getting nowhere
So i called a reference to the TankBarrel then a GetWorldRotation and into a clamp and added that to my action value but cant get it to work correctly. I also changed my TankBarrel to start out at the “0” position to make this slightly easier lol.
You might find that using world rotation doesn’t work when the tank turns, that’s why I said local, but see how it goes ![]()
Also, you need the clamp as part of the code, otherwise it’s not doing anything ( I’m not sure if you thought it was executing or not ).
Oh nah I was connecting it to my print screen so I could visualize the rotation degrees lol. I’m a beginner so I’m trying to learn the way different things function. I used the clamp as part of the code but the action value is only ever 1 for my “angle up” or -1 for my “angle down”, I cant figure out how to get the rotation degrees as part of the code so i can clamp it
I did that the first time but lemme try again lol when i go from the ReturnValue of the clamp and go into the print string, it only shows a 1 or -1 depending on which control I’m modifying. I’m heading into UE5 to try it out now
Yea same issue. There’s only a display of “-1” on the screen from the printstring i tied in. Wouldn’t i need to get the rotation and then tie it in prior to the clamp?
Sorry. You can do this kind of thing

Notice that, because the barrel is just a cube, the pivot point is in the wrong place
So I used a scene in the hierarchy to get the barrel to turn from the correct place
A scene is just an empty component you can use as a sort of invisible placeholder.
You can use ‘add relative rotation’, if you like, but then you still have to clamp it on tick
Oh man, don’t ever be sorry! I’m still a beginner and even through failure I’m learning and best believe that when I finally release what I’m working on that you’ll be on my list of thanks and gratitude
I know that’s not much but it means the world to me. I’m 40 years old and 2 years ago I told my kids that I would make a game for them; me being me I thought it was gonna be drag and drop and simple…I’m wiser now lmbo. Anywho, I’m about to try what you suggested, gimme a little bit.
That’s a winner!!! You dunno how grateful I am for your patience and your time! May i pick your brain for future problems that I know I’m gonna have lol?
Sure thing ![]()










