Moving camera towards right gamepad stick direction

Hi!
I’m working on a mobile twin stick shooter and I have been trying to figure out how I could smoothly move my camera a little bit towards the direction I am shooting with my right gamepad stick to create a bigger field of view.

Here’s an image of the blueprint as is:

Now I was thinking that I must take the axis values and make them into a vector and then somehow add them to the camera location to be able to move it the direction I am shooting, but my attempts have not worked.
A friendly hand would be dearly appreciated! :slight_smile:

Additional info: the camera movement I would like to achieve is very akin to the one they use in Nuclear Throne - Nuclear Throne - Gameplay Trailer - YouTube
So instead of having the camera move towards your mouse position as in Nuclear Throne, I want the same thing to happen using my right stick towards the direction I’m holding it

You can use the AddRelativeLocation node of the camera component and move the vector of your axis input.

In the example, FireFoward and FireRight are my InputAxis for the Right stick and then rotated it since the camera is facing down.

Hi, thanks for the reply. I am having trouble figuring out how I can reference my players camera component into the player controller. What should I do?

I don’t know exactly how you project is setup but I’m assuming your camera is in your player pawn? If that’s the case just get the pawn with the “getControlledPawn” node and cast it to your class of player and then you should be able to get the camera component.

Hi again, you are right and I tried casting it and it works! :slight_smile: But now I have some follow-up questions if you are able to help :slight_smile:

I got the camera to move in the direction I want but there is no limit, and it just keeps going into infinity. I’d like to add a limit, and I guess I need to use the VectorLength somehow to do that.

The second thing is that it could be cool if I could somehow create a fast but smoother reset when I let go of the right stick. I recorded a video for you to see what I mean:

Also here’s an image of the blueprint right now.

For setting a limit just add a branch before you move the camera forward and of the vector length of the camera’s relative location is equal to or above the limit do nothing.

As for making the camera reset smoother but fast just try change the value you multiply the camera’s location against. (i.e. Make it smaller to slow it down, -.01 or -.1) it would probably be easier and better if you made a variable for it like “CameraResetSpeed” and multiplied times the delay seconds so as to make it the same speed no matter the computer.

Awesome, the camera reset works, and lol what an easy fix :smiley:
The only thing left is a weird thing happening with the camera if it hits the limit.

It just gets stuck on that location and does not change if I rotate it any other direction unless I reset the camera

Oh, sorry. The camera gets stuck because once it reaches the max it doesn’t want to move anymore. If you want to have an effect where it still moves in the max you will have to “predict” the new location.

This is actually simple using the “Clamp Vector Size” Node. Just add your Delta Vector to the camera’s position to get the prediction then clamp it to your max and then subtract the position to get the new delta that is now clamped.

example:

I am sure to be doing something wrong, I’m guessing I am using the wrong Delta Location, because that’s the one confusing me :smiley:
Here’s an image:

Oh, sorry. You need to remove the 2nd Branch (The one for max length) since the clamp node handles that instead (it will set delta location to 0 when at max).

It works perfectly now! Thank you for your help, you da man! Have a great day :slight_smile: