|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
Luke Fenstad |
I’m trying to make a camera for my game, and I have no idea where to even start. I just started learning the engine, and I don’t know what nodes to use or how to program them. I’m trying to make a camera similar to something like Super Metroid. Does anyone have any idea how I could do this?
|
|
|
 |
Reply From: |
zhyrin |
There is a Camera2D
node, that’s a good start. If you want this to be the active camera, you have to enable
it. If you make this camera node a children of your character scene, it’ll follow the character automatically.
The camera has limit_top/right/bottom/left
members that can constrain it to a specific area. Even if the camera is poisitioned in a way that it would show what’s outside of the limit, the image will be limited to these values.
This is useful if you want to restrict the camera’s movement to the current screen of the game. When you enter the next room, you would need to update the limits on the camera based on the new room.
I did something similar, check out this game: Through the Looking Glass by Zhyrin
Note: this is in godot 3.
The project is open source, although I wouldn’t blame you if you said the code was hard to understand 
Anyway in this script https://github.com/zhyrin0/through-the-looking-glass/blob/main/src/world/world.gd
you can see _on_Level_entered
and _on_Level_finished
are responsible for changing where the camera is limited to.