Repositioning the camera based on the player's vertical location in a sidescrolling game?

Hello once again, I was wondering if anyone could help me out with my custom camera blueprint.

You see, I’ve been using a custom blueprint that that establishes a dead zone that keeps the camera from moving when the player jumps, based on tutorial video I found on YouTube:

The setup from the video works perfectly for keeping the camera from moving as long as the player is within the dead zone but creates a problem.

That problem being that as you can see in screenshot above, the camera is now positioned in a less than desirable way than from the player character’s starting elevation.

So to fix problem I’ve been looking into platform snapping. If you’re not similar with the term ‘platform snapping’, Game Developer article [Link] defines the term as when the camera repositions itself relative to the player’s location when the player is standing on solid ground above an invisible boundary line, as seen in these examples:

marioworld_platformsnap_240

rayman_5_240

I realize that sounds like a lot but the thing is that the ‘dead zone’ camera blueprint I’m currently using already has something like .

If the player character jumps up when they’re at a elevated position then the camera will move upwards, repositioning it into a more desirable position.

The problem however is that has to be done manually with the player jumping when I want I want the process to be automatic.

The camera should automatically move upwards when the player is standing on elevated ground.

However, in order to accomplish I need help as camera blueprint is rather complicated and I don’t really have the knowhow on how to get the camera to work the way I want it to.

I’m fairly certain that triggering the camera’s movement will involve using the Event On Landed node which I’m already using in my character master class blueprint.

event_on_landed

But beyond that, I don’t know how to go about creating the invisible boundary or actually moving the camera once its triggered.

As always, any help whatsoever would be greatly appreciated!

Event graph:

Construction script:

New Y value:

New Z value:

I think you can just add your own camera movement logic without messing up with the dead zone.

You could use OnLanded but that would mean snapping the camera instantly when you land, which would look bad. Also it wouldn’t handle slopes like Rayman example.

With Tick you can check if character is on ground, and update camera Z smoothly to match ground Z. Something like :


should be a good first step, but you’ll probably run into issues if you jump again before the transition is over. A solution would be to store the last known ground position and continue transitioning to that.

But then another issue might rise as it could conflict with dead zone in certain situations. For example if you keep going up and past the dead zone, camera will move up, but the ongoing transition will try to pull it back down. Same if you fall down before up-transition is over. So I’m thinking we can avoid that by also storing the direction of the current transition, then we can detect if camera crosses target or player crosses camera.

got a bit more complex than I thought…

1 Like

So I got the revised camera setup working but with a major glaring issue.

The camera for some reason is positioned way too high, specifically, it appears that the camera is centering the player character into the middle of the screen.

The camera by default should be positioned like and not the above.

I’m not sure if I have set up wrong or not but why is the camera position being adjusted from the start of gameplay?

The “platform snapping” functionality of the camera is only suppose to occur when the player is standing above an invisible boundary, otherwise the camera isn’t suppose to move unless the player character moves outside the camera ‘dead zone’.

There is no invisible boundary in my sample, the camera will always adjust according to ground height where the player is (or last was). is more akin to the Rayman example, where you can see the camera adjusting as he is walking down the slope.

And yes I’m using character center as a reference point. If you want it to be higher it’s not difficult, simply add an offset when defining the target Z :

1 Like

Okay, that change worked.

But there’s a bit of an issue where I can only change value up to a maximum of 200; any higher, even by 1, and it starts causing issues with the camera, messing with the dead zone.

Otherwise things are working fairly well and thanks for the help so far! :slightly_smiling_face:

That’s because your dead zone is centered around the character as well.

You can offset it the same way in the dead zone blueprint code :