How to lock camera y-axis so it only moves forward?
Hey, I'm using the third person template to create an endless runner-style game, and I'd like the camera to stay locked on the y-axis when the character switches lanes so that it keeps moving forward with the character, but won't receive any input when hitting A or D, thus staying centered. I've tried numerous different solutions on here, but the camera stubbornly continues to follow the character.
How would I go about locking one of the camera axis'? Thanks in advance!
Edit: Thanks to @vicecore and @aNorthStar the problem has been solved! Here's the final node setup in the character blueprint, in case anyone else is struggling with this (just ignore the couple of nodes that are hooked up between Event BeginPlay and Event Ticks that aren't in aNorthStar's instructions). Thanks for the help guys! :)
@vicecore is on the right track, I think the most attractive, simplest and performant way to do this is to :
Camera Rig BP -- create a new actor class in BP, maybe call it "BP Camera Rig"... and attach a spring arm component to be the parent and add a camera component as its child. On the spring arm component, turn off use pawn control (on both spring arm and camera components) and inherit pitch / yaw / roll. As desired, angle the spring arm and camera, set the spring arm length, adjust the socket offsets as it suits you. Spring arm lag will nicely smooth the camera speeding up and down to follow the player position.
Player Pawn / Player Controller BP -- In your player pawn actor class... with Spawn Actor From Class spawn BP Camera Rig in BeginPlay and create a variable a reference to this actor... use Set Target With Blend with a reference to self and the BP Camera Rig as the target (this ensures that the right camera is selected).... on Tick, Get Actor Location of self (i.e. player pawn) and Set Actor Location of the variable referring to BP Camera Rig. . this sets the world location of the player pawn and camera rig as the same.
if everything is set up right, this should work just fine. any issues, just post here :)
Follow this question
Once you sign in you will be able to subscribe for any updates here