Camera follow player

Hi
Usually I manage to figure out how to do things and get it working, but this time im stuck.
Im trying to make the camera follow the player just a little bit when the player jumps. The reason for this is that i want to be able to see some of the ground that the player was walking on. But it looks kind of stupid if the player is jumping out of/past the top screen. And i dont want the game to be nodding up and down to much when the player is jumping.

Does someone have an idea of how this could be achieved? :slightly_smiling_face:

Maybe, check if the player is NOT colliding with the platform, then make the camera follow the player

Getting the camera to feel right is pretty tough… but what you are trying to do sounds reasonable.
First the easy way, assuming the floor is along the bottom of the screen:
If player.Y() < SceneWindowHeight() - Player.Height() → Set the Camera Y position to SceneWindowHeight() / 2
If player.Y() >= SceneWindowHeight() - Player.Height() → Set the Camera Y position to “lerp(CameraY(), Variable(Player.Y(“Center”)), 0.5)”

The harder way (which I wish I had thought of before) is if you want the camera to dynamically “stick” to the last platform you touched. In that scenario you will need to add a ray cast from the player’s feet to check for a platform object, and save the Y position of that platform as variable called FloorPosition. Then adapt the above logic to check against that variable like this:
If
player.Y() > Variable(FloorPosition) - Player.Height() / 2
player.Y() < Variable(FloorPosition) + SceneWindowHeight() - Player.Height()
→ Set the Camera Y position to Variable(FloorPosition) + SceneWindowHeight() / 2
If
player.Y() < Variable(FloorPosition) - Player.Height() / 2
OR
player.Y() >= SceneWindowHeight() - Player.Height()
→ Set the Camera Y position to “lerp(CameraY(), Variable(Player.Y(“Center”)), 0.5)”

This is all just from the top of my head, so expect some logic/syntax errors

Thanks for all help. Will check out the ray cast and see if i manage to get it working.