Find somewhere in player code/blueprint vector operations like player_position + offset = camera_position. After that operation you need to get camera world position, set Z to some constant number, and then set camera world position with this vector. That’s all.
There is actually big number of ways to do this. Solution above is simple and pretty fast.
How to:
This is not code, it all can be done in blueprints.
Ouch, this is uses spring arm, didn’t know it.
But anyway I’ve created side scroller and opened character blueprint.
Then in blueprint created Event Tick (called every frame). Notice, that in spring arm properties in the right side there is Traget Offset. If we can see variable - then we can use it!
Then I made variable for camera’s height.
Dragged spring arm to event graph, then dragged node, in search printed “Offset” and chosed “Set Target Offset”.
Doing all the same with other components do something like this:
This is easy scalar (not actually vector) calculations, you’ll figure out
And viola! Try this out, it works, but i’am out of attachments here.
And yeah, you need to turn off “Do Collision Check” in spring arm settings, or camera will sometimes go into walls.