Use Game Pad to Move Camera Down & Up

I want to create a very very simple first person blueprint that can use an Xbox gamepad to pilot a camera in-game.

I want the controls to be identical to the in-editor gamepad control defaults where R-trigger and L-trigger move the camera up and down.

For some unfortunate reason, when in-game, Unreal’s default controls change to the A button moving camera up, but no button to move down.

Please help, I know this is very simple, I’ve been searching for hours for documentation with no luck.

Thank you.

You can add InputAxis in ProjectSettings->Input. Add a new one, call it e.g. “VerticalMov” and add two inputs. One for Left-Trigger and one for Right-Trigger. Give one the multiplier 1 and the other one -1. Then in your blueprint add an InputEvent (right click and search for “VerticalMov” or what ever you called it) and multiply it’s axis value by the vector you want to move it (e.g. x = 0, y = 0, z = 5). Add these result as “AddRelativeLocation” to your Actor/Camera. This will move the camera every frame 5 units up/down (depending on the button you pressed).

Hope that helped! :slight_smile:

This is very helpful, thank you for explaining it! From what you suggested, I’ve continued to map the Left-Thumbstick to move the camera along X and Y vectors, and mapped the Right-Thumbstick to pitch and yaw rotation.

I seem to be running into a problem: these transformations to the camera need to be relative to the camera’s view for the controls to make sense to the player. I feel like it could be accomplished with some math applied between the movement vectors and rotators, but I’m not sure how to express it.

My end goal now is to create a Pawn blueprint that mirrors the Xbox One gamepad controls in-editor.

If you can point me toward how to keep the transformations oriented to the view, I think I can reach my goal. Thank you for your time.

You can use the “Get Actor Forward Vector” (or something like this). This will give you the normalized (length = 1) vector of the direction the camera (or the actor) is facing at. Multiplying this vector by e.g. 5 and adding it to the current location will move your camera forward. The same node exists for left/right and up/down. If it’s only exist for right and you want to use it for right, multiply it by -1 or simply multiply it by the axis of the Input Event. Hope that does the trick for u :slight_smile:

Example in pseudo code:
InputHorizontalEvent(float axis)
Actor.AddRelativeLocation(Actor.GetActorRightVector * axis)

Yes! this works thank you for helping me. I appreciate you.

glad, that I could help :slight_smile:

So with my first goal accomplished thanks to your help, I’m adding other inputs but realizing that the movements are generally rigid and linear compared to the default editor controls. Gamepad controls are usually smoother interpolations and sometimes the camera has a bit of inertia. I tried adding making the camera a child to a Spring-Arm, but not sure if that’s the solution. I’ll provide my file in case you or anyone has time or wants to take a look. No pressure, anything helps! link text

Hi! You can also use Physic Based Movement. Simply use the [node] and tick “Add to Current”. Or use “Add Force”. This will require a vector parameter, using the one you already created should work (I can be wrong, never tried it before).
An other way could be using Timelines. You create one with an eased curved as the alpha and then lerp between your final vector and a 0-vector. This will smooth your movement but attention: You have to adjust your controls from axis to action, and do the timeline only once. Save the value of the output (alpha) in a global variable and set a bool, e.g. HorMovementStarted, to true. In the tick event of your Pawn class you will check if that variable is true and then use the alpha of the Timeline to lerp between a 0-vector and your final direction vector. Add the result like you did before.
But here’s a problem: you can’t move the camera different “fast” depending on how you move the analog stick…

I would recommend you to test the physic based movement.