Rotate the camera independent of the controller, like a Tank turret?

So here’s the TL;DR version of what I’m trying to accomplish:

I have controls for moving forward and backward and turning the controller set to the keyboard. These all work as I expect them to.

What I want to do is set it so that the camera and Mesh1P rotate left and right via the mouse input, WITHOUT turning the character controller. What this should allow me to do is continue walking “Forward” according to the controller, but be facing perpendicular to the direction I’m walking. A real world example of this is a tank, whose turret can rotate on the base. The base moves, so does the turret, but it doesn’t move the direction the turret is facing.

Does that make sense?

right click in the BP, disable the context filter, and search for mouseX and mouseY. That will give you the lateral mouse position, which you can use to modify your “turret’s” rotation

That makes sense. My question is the actor portion of it. Do I need to have a new static mesh for the turret mounted to the base? Does the turret have to be its own blueprint, or can you rotate a component of the pawn? That’s where I’m mostly getting hung up: the actual components involved itself.

I would be interested in seeing this work. I think the best approach is to use two different blueprints, one for the chasis and one for the turret. I’m not sure what comparative function UE4 has, but when coding something like this in another 3D engine I would use a pivot. If you can attach a pivot to the chasis as a child, then attach the turret as a child to the pivot then would work. You would then set the keypress driving BP to the chasis and the mouse movement BP to the pivot. When driving the tank chasis with the keys the turrent should automatically move with it.

This set up would allow you to swap turrets too for different fire power :slight_smile:

Sweet, thank you 6. I’ll take a look at this right now and report back once I’ve had a chance to test.

You can do it in the same BP. Bring in your tank chassis as the root mesh, then just drag in the turret mesh and it will be a child of the root mesh (the tank chassis). You can then select the turret mesh and move it locally to the place in the chassis it’s supposed to be, and then it will follow the tank.
Ideally, you’d have TWO children mesh components. A turret base and a turret barrel. You’d use mouseX to drive the horizontal rotation of the turret base and mouseY to drive the vertical rotation of the barrel.
Post back here if you’ve got it, or if you still need help. If you want I can throw together a sample tonight.

The sample will help, zorque, but I’ll definitely give this a try today. I’m working on some assets to test it with, as I don’t think the little standard ones will do what I want them to.