Metroidvania Style Camera

Hello All,

I’m currently stuck on how to get GDevelop’s camera to behave similar to a Camera in Metroid or a more recent Castlevania/Bloodstained game.

This would mean the camera follows 3 rules:

  1. In most scenarios follows the player, except for the below situations.
  2. Stops moving on the X or Y access if it would display “past the wall/floor”
  3. Stops moving on the X or Y access if the player reaches a Door, such as to a Save Room or Boss room.

Here’s an example:

Notice a few things in this example:

  • The camera initially only follows the player on the Y axis, because following on X would display past the wall.
  • When going to the room that is only 1 screen tall/wide, it doesn’t follow the player at all.
  • The camera only centers on the player if it wouldn’t expose past the wall
  • Upon entering the save room, the camera snaps to the center of the save room
  • After exiting the save room, the camera snaps back to NOT follow the player (which would expose part of the save room), but instead moves back to a spot where the player is infront of the door, and the camera doesn’t expose “past the wall”.

Does anyone have any ideas of a clean(ish) way to do this?

Originally, my thoughts were:

  1. Create a hidden screen sized object (CameraCollision) that is centered to the Camera X/Y. This allows to detect for “is something visible on the screen” and “is something about to collide with the screen”
  2. Create a hidden screen sized object (RoomCollision) that sits over the save room.
  3. Set up events so that: the Camera follows the player unless CameraCollision is in Collision with RoomCollision, wherein the camera stops.If the player is in collision with RoomCollision, the Camera centers on RoomCollision.
  4. The ALMOST worked. The camera does stop moving right before you reach into the save room area. The Camera then does jump to the center of the save room no problem once the player enters it. The issue is that when the player LEAVES the save room, the camera stays put where it is on the Save Room. I’ve also tried to use the “Separate objects” event but that doesn’t seem to work, either.

Any/all input is greatly appreciated.

1 Like

Doing some additional digging, I found some examples people put up for GameMaker Studio and Unity, talking about making “BoundryBox” objects for each contigous room. This seems to work.
Here’s my events:

Does anyone know if there’s an easier/cleaner way to do this, or does this look accurate?

Do you know how to add a Camera effect like in the game Celeste, Whenever we touch the edge/the door the level moves and the player will be able to move.

Please don’t bump 2 year old threads.

I’d recommend making a new topic in the How Do I? category to cover this. Although I do think you could take my camera events and tinker with them to do a gradual “slide” by using the Lerp() expression.