How do I setup 'Tank' controls?

Hi all so I’m trying to set up a custom movement for a dummy char atm.

I followed this tutorial for the initial WASD movement: Unreal Engine 4 - Beginners Guide to Player Input (1/2) - YouTube

But what I’m trying to do is have 3 mesh cubes to simulate legs/torso/head, I have parented them legs > torso > head and want the WASD to move the legs which works fine, I then want the mouse to rotate the torso to a fixed 160 degree yaw only which would also effect the head then have the head moved with the mouse + a modifier (i.e. Alt/CTRL/Shift) to allow the ‘head’ to rotate 180 degrees yaw (in relation to the torso) and maybe 90 degrees pitch.

I thought i could use the Axis mapping for the leg/torso movement and maybe action mapping for the head but am struggling. I thought it would be quite straight forward but it won’t allow me to apply the torso or head to the ‘target’ of a Set Actor Relative Rotation, or Yaw Input or similar.

Also as I followed the tutorial above there is a CapsuleComponent as my [ROOT] which I can’t remove/replace, is that an issue?

Where am I going wrong? Thanks.

Hello,

Making this type of movement has come up many times before, so I decided to create a tutorial so that it could be reference easily. Please take a look at this:

Let me know if this helps at all. If not, I will be happy to further assist you.

Hi thanks for the above, I found it really helpful and has set me in the right direction but I’m not quite there yet.

Although I mention Tank it more like a mech control, so I now have the Legs (base mesh) which uses WASD to move forward/backward and strafe, I have also set up Q & E to rotate (yaw) the legs.

Using your tutorial I have now fixed it so my body rotates independantly of the legs (I’ve yet to restrict the rotation but sure I can figure that out later)

So I followed your tutorial to figure out the above but have added another mesh (the head), parented it to the body and parented my camera to that instead of the turret (body in my case).

I thought I could use an Action Mapping with Alt and Mouse X/Y so that if Alt is held down the mouse movement doesn’t move the body but instead moves the head in both pitch and yaw so this is the point I’m upto now and I’m not even sure if I can use:

a: The action mapping, as even though it allows me to enter Mouse X or Y as the binding, when I use it in the blueprint its just a pressed/unpressed so maybe I can get a constantly updating value such as a mouse movement/position.

b: The mouse movement for two seperate controls, the body rotation AND the head rotation/pitch when a key is held down (though based on the complicated stuff done in examples I’m sure this is childsplay :P)

Couple of images:

Character layout: (apologies for the inapropriately placed arrow!)

Blueprint so far

Jusr realised I hadn’t even looked at the barrel part so I’ve managed to get the head pitch in (as the mouse X isn’t used for anything else)

Just as a follow up to the above I am linking images of how I set up head/body/legs independantly, currently the head moves with Mouse Input though I imagine it would be straight forward to replace it with Occulus Rift movement (?)

Base (leg) Movement

Body Movement (yaw only - clamped)

Head Movement (yaw & pitch - clamped)

I have a new issue now (not sure if I should post new topic but it is related) I want the player to be able to press RMB and your weapon will move up to an ironsight position based on the orientation of the head, it almost works however as I have the body as the parent (to avoid it yawwing when in the holster) when I attempt to adjust the transform of the weapon to put it at eye level because it is relative to the body it is offset in relation to the head (slightly in pitch but dramatically for yaw.

Images below (I know the weapon needs to move even further forward to stop the clipping):

How can I best ensure it moves to exactly the head orientation rather than going of the body location/orientation?

Hi Verbal_K,

I’m making a test of this based on what you have provided, but could you send me a screenshot of how you are doing the ironsights in the BP? That is the only thing I think I may be doing different from you.

I just have two scene components that I switch between parenting the camera and I am not seeing any rotation issues.

Hi, Link is:

That was the last iteration, I tried a few other methods but your comment on ‘switch between parenting the camera’ makes me think I was going about it the wrong way :stuck_out_tongue:

You probably realised but the ‘Released’ links to placing the pistol model back on the character hip.

It depends on what you are trying to accomplish. With what I’ve done, the camera basically exists at one of two locations that I have as Scene Components in my BP. It is an instance switch, without any smooth transitions.

The scene components are parented to the MountedGun(Head) or Turret(Torso), so that when the camera is parented under them, it will follow their movement while maintaining the offset I want.

It is really just one method of many. Let me know if this helps.

I think this may work (unfortunately I won’t be able to check until later)

As if the gun was parented to the Head, I’m fairly confident I won’t have the issue.

So If I can switch its parent on the RMB press (which it looks as though you are doing above that should sort it.

I’ll post my results once I try it later.

Thanks for the help.

Hi looks like the above will work, just need to tweek some values, thanks a lot much appreciated :wink:

Quick video to show what I ended up with, thanks for all the help :wink: