I'm working on a camera that can move in between levels, similar to the camera in celeste. At first I tried using a Tween to interpolate the limits of the camera. It seemed to work at first, but I soon found that it caused the camera to move unevenly when the levels where different sized. So I then tried to deactivate the camera's limits, interpolate the camera's position, then set new limits. However, I couldn't seem to change the global position of the camera since it was attached to the player. Does anyone have any idea how I could approach this problem.
Camera Moving Between Levels
Quick question to go with this post, how does Godot account for camera limits? Godot doesn't seem to modify the position or offset of the camera when keeping the camera in the limit. If I can find out how Godot keeps the camera in the limit without modifying it's offset from it's parent node, then I should be able to move the camera freely without detaching it from it's parent for switching camera's every time the player moves to another level right?
@David -- it isn't clear at least to me what problem you're having, or enough context to understand it. Could you post more detail, or ideally a small dummy project showing the camera moving "unevenly"?
@llasram Currently, I'm working on a 2d platformer game where each level is split into many chunks, each of which are around the same size as the screen. When the player dies, they simply respawn at the beginning of each chunk, instead of loosing lives or starting over. The camera would be limited to the chunk the player in currently in. I'm trying to code is so that when the player enters a new chunk, the camera to slowly pans to the new chunk,.
The solution I'm trying out right now is to detach the camera from the player, making it easier to manipulate its position. I'll post again if it works.
- Edited
You can create an invisible node that follows the character. The camera should be on that node and not on your character. When the character dies, you move the node slowly towards the screen fragment you want and the camera will follow. You could also add a movement delay in the node. This trick is sometimes used to give a smoother movement to the cameras.
@Zelta I'll definitely try that out.
Good news! I've solved the problem by detaching the camera from the player and hand coding the camera's motion. I'm planning to try attaching the camera to a node2d with movement delay later, in order to make the movement smoother.
- Edited
Hey @David Im searching for a camera like in celeste too. Can you tell me the code for the camera?