Have tank turret match rotation with Camera?

I have a tank animated, moving, shooting etc but at the moment the turret rotates according to the springarm rotation (immediate new position etc). I would like the camera to look around at whatever speed the user moves the mouse but I would like the turret to rotate and gun to elevate at slower rates and end up matching the camera (many games are like this but the most popular current one is War Thunder) I’ve been experimenting and thinking I could get the camera yaw and pitch, compare that to the turret yaw and gun pitch then add/subtract the rotations until they match.

Camera rotation is easy to get but I can’t seem to figure out how to get the turret rotation or gun elevation values. I’m really flummoxed here.

Can’t seem to find any tutorials or anything that would help me to I’m hoping one of you may provide some clues as to how I can do this?

Hey @Patwww!

Yeah you should be able to get Camera Rotation from “Get World Rotation” and use that.

What you’re going to want to do for the rotation and gun elevation is use LERP. I couldn’t tell you how to set the turret to go at certain speed with every rotation combo though… Maybe do a clamp on the rotation speed and plug that into the lerp alpha. All of this would be on tick. :slight_smile:

I hadn’t thought of using lerp, I was going to add a fixed amount and fudge around to get the final matchup but lerp/clamp
does that for me - thanks for the reminder

1 Like

Still can’t figure out how to get the bone rotation inside the pawn blueprint. Can’t seem to find any way to set a proper target for Get Bone Rotation (one is posable while the other is mesh.

Hey again @Patwww!

So can you be a little more specific?

“One is posable while the other is a mesh” Can you elaborate on this?

Sorry that was in the middle of many experiments so I don’t remember exactly but I think it was using a pawn blueprint in a UserWidget and tryin to use it’s mesh for rotating something the two looked like similar objects but turns out they aren’t.

I ran across a possible but of help with a UI tutorial that shows turret rotation as a rotated icon. Going to follow that one down the rabbit hole now.

I think I’m getting closer but I could be way off. I’m just trying to print a bone rotation (yaw) in a HUD (userWidget). but all I get is zeros. Can I do it this way at all or am I barking up the wrong tree entirely?

I’m really just trying to figure out how to get my turret yaw value in a HUD or ABPrint. I can get the camera rotation but still cant figure out how to find out where my turret is pointing.

Hey @Patwww! Can you show where you’re getting that “As BP 72” reference?

It’s possible that you’re not getting an active reference.