-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multiplayer camera #9
Comments
Add a new camera that inherits from Camera2D. It can frame the player characters by positioning and zooming accordingly. It adds a margin of 128 px (one tile size) to the player positions. Add a new node for this camera to the main scene. It is disabled by default. So by enabling this one and disabling or removing the current camera for the character, this one takes precedence. The new multiplayer camera has the same limits and position smoothing that the current camera. This is based on the Godot recipe [1] but adapted to Godot 4 and to this project, with variable names improved. [1] https://kidscancode.org/godot_recipes/3.x/2d/multi_target_camera/ #9
The background didn't work when zooming out either the existing camera or the new multiplayer camera because it doesn't repeat vertically. Adapt it to work: - Enlarge the farther layer using a ColorRect so it can cover the screen vertically at 0.4 zoom (the whole default level). - Also set the background to not follow the camera zoom. #9
Implemented in #12. |
As of commit a1d098c, starting from a clean working copy, I did the following, following the steps described in
I think this property is confusingly-named. Selecting "Two" works fine, modulo Dvorak Problems that I'll open a PR for.
I get this crazy flickering effect: Screencast.from.2024-11-12.09-50-12.webmI think what's happening is that the players are intersecting so they're doing some weird collision. I guess the instruction above didn't mean “move it next to the existing player in the scene tree” but “move it in the canvas so that it doesn't overlap the first player”.
Both players have a camera because duplicating the player duplicates its children too.
Very nice! |
I had a quick poke around to see if there's some way to make the players overlapping automatically fix itself but it got pretty nasty pretty fast. Maybe it's a fun thing for learners to find for themselves. I tweaked the documentation in #13. |
In the Moddable Platformer, we would like the ability to show multiple players on screen at once. We can probably get away with a camera which zooms and pans to contain all of the players. Ideally this should happen "for free": the camera we have built in to the game should understand how to follow however many players exist in the scene.
The text was updated successfully, but these errors were encountered: