Get camera to move only up, but not down

Hi everyone.

I am trying to set up a side-scroller camera so it moves only up with the character when jumping on a the next platform but not down, when the character misses a platform, or in other words, is falling.
Very much like doodle jump or many other platformer out there.

I am not much of a coder, so my expertise isnt that great and apparently i am missing something here.

I am currently asking if the player “is Falling” and if true, detach the camera. But this is not working.

Another approach was to calculate if the Z velocity is below 0 and if true, detach the camara.
But this is also not working.

Anyone got an idea on how to solve this?

create a separate camera actor custom blueprint, position it how you want at start of game, and in your player control, set view target with blend to this camera. then in your custom camera’s tick, create a new function that specifically handles movement. for the movement calculation, get the player location’s z value. in your camera, VinterpTo that z value with a ‘set location’, but add a branch that check’s to see if the move direction’s z value is positive or negative so the camera know’s only to move when things are going up.

Hi paradoc,
thank you, with your help i got it working.
First i had problems getting a reference to the camera inside the playerBP.
(“Set view target” needs this reference) I didnt know you can spawn actors from class, now i know and it works. thanks again.

Thanks for this answer. Really helpful. Also, thanks to DAkAR for the bit about needing to spawn the camera from within the player character class. I was trying to just drop the camera in the map, which didn’t make sense but the directions weren’t crystal clear on that part.