Camera movement when player reaches an area


suppose I create a topdown game that has a very large map and I would create each section in a separate scene.

How can I make it so that as soon as the player stands at one of the (camera) “edges” of the section (he reaches an area), that the camera moves to the next section like in Zelda?

This is independent of whether the player wants to walk to the right/left/top or even down.

:thinking: I believe @Entropy404 was working on an extension for this

And without an extension, how to do it?

Adding sprites to act as zones then limit the camera to the zone that player is in collision, like in metroidvania style games, i think @Silver-Streak has some sample of that with a minimap

Here is a game here you can check i don’t know if is this what you want to achieve in the Red Laura game the player can move through zones and the camera is limited to the zone that Laura is. If you want i can share some of the event to do it.

1 Like

Thanks, but it’s not how the camera moves like in zelda game (or the camera moving is very fast).

Take a look here Gdevelop: ZELDA SCROLLING Tutorial - YouTube maybe helps.

Have found this video too, but this is only if the “map” is big (one scene).
Mine isn’t it (because i will have more scenes)!

You will not be able to do the type of transition you are attempting (Zelda-overworld room “sliding”) for different scenes.

However, as UlisesFreitas mentioned, you can probably do this with objects that act as a “Room” for your camera, then set up an event whenever you transition from one to the other. You can see an example of the basic idea here: GDevelop Metroidvania Camera Example by Silver-Streak

1 Like

If you use External Layouts for each of the “level segments” in your larger meta-level, then you could develop logic to load the external layout for the next scene at the current offset, then slide the camera over, and then remove all the objects from the previous scene.
If you are a beginner then this is probably a lot to learn (I’m not sure anyone has done this, but I’m convinced it’s the best way to do an open world game) and you should consider whether you really need to slide transition between scenes.


I would love to take you up on your offer of sharing the events.:blush:
Could you do this with scenes and not with only one big map?:heart_eyes:

I know i’ve to learn a lot of gdevelop first… but the idea of loading the next scene on an current offset to slide the camera - like in zelda - to the new area is interesting.:wink:

I’ve never played zelda, but I assume if you are just looking to smoothly transition the camera you could have a “camera center” object, and have the camera center on it, and add a force when the player goes into a new level

One week ago :blush: i wrote that i would to love to take you up on your offer of sharing the events but so far nothing happens. :cry:
I’m sure you just forgot unintentionally.:wink:
I would be very happy if something would come.

Loading the new scene if the player reaches the area isn’t the problem - i’ve done this.:wink:
My problems are:
-in the new scene the player is on the wrong place (don’t know how to fix that)
-there is no “smooth” camera sliding (only loading the new scene; player is in collision with… change to scene…)
I do not have any code/events for this! So please do not ask about it.

Is it important to remove all the objects from the previous scene?:thinking:
How to do that?

Have you any event for this?:blush:

Hi there I have no example for this never tried I just point you to Zelda Scrolling Files for GDevelop by Sparckman
Maybe you can ask @Sparckman if he can share some tips of this game creation.

Sounds bad.:cry:
I mean you point me on the other game:

So i was hoping you can showing me the events - for this game - but just with switching scenes. :wink:

Yea you need to remove the old objects eventually otherwise you’ll run out of memory. I would start with assigning a chunkId to all the objects when you load them. Then keep track of the loaded chunkIDs and remove all the objects for old chunkIDs or perhaps all chunkIDs that don’t neighbor the current chunk.

1 Like

Now we are OffTopic, but what is a chunkID :blush: and how to set and use it? :thinking:
Any example?

The chunkId would just be any unique number or string to represent all the objects on a particular external layout. Presumably you would also create a matrix containing all the chunkIDs and their relation to each other so you know which ones neighbor each other.

1 Like