Skip to content
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

[3.x] Add a 2D version of the dynamic split screen demo #762

Open
wants to merge 2 commits into
base: 3.x
Choose a base branch
from

Conversation

BenjaminNavarro
Copy link
Contributor

@BenjaminNavarro BenjaminNavarro commented Aug 3, 2022

Here is an updated version of the dynamic split screen demo project that now includes a 2D implementation along the existing 3D one.

It took me some time to figure out a way to do this in 2D as cameras and viewports behave differently compared to 3D. In the 3D version there are only 2 additional viewports, one per camera. In 2D, I had to create a third viewport to hold all the game content and share its 2d_world with the two other viewports. I don't know if there is a better way to do this.

The shader is the same for both 2D and 3D but the scrips are all slightly different.

I also reworked the 3D scene so that it's more similar to the 2D one (due to its 3rd viewport limitation)

See #762 (comment)

Bugsquad edit: This closes #650.

@BenjaminNavarro
Copy link
Contributor Author

After the offline suggestion from @NathanLovato to use only 2 viewports in 2D as well (didn't thought about it) I refactored the project a little to make it simpler and more consistent across the 2D and 3D versions.

I pushed a new commit so you can inspect both versions if you want, I'll squash them later after the reviews.

The main changes are:

  1. The node hierarchy is the same for both versions (except for Node2D/Spatial and Camera2D/Camera of course)
  2. I merged 2d/camera_controller.gd and 3d/camera_controller.gd into camera_controller.gd. I detect if the script runs for a 2D or 3D scene, set the mode enum and use it in a couple of places to handle the difference between the two modes. Since most of the code was the same I think it's better now considering future maintenance and updates but I can roll back to two different scripts if you think that would be clearer to users

@akien-mga akien-mga changed the title add a 2D version of the dynamic split screen demo [3.x] Add a 2D version of the dynamic split screen demo Feb 28, 2023
@akien-mga akien-mga changed the base branch from master to 3.x February 28, 2023 17:34
@aaronfranke
Copy link
Member

This PR has a few conflicts and needs to be rebased.

In general a 2D version of this demo seems nice.

 - both 2D and 3D scenes have the exact same hierarchy
 - a single camera_controller.gd script instead of one per mode
 - the third viewport for 2D mode has been removed
@BenjaminNavarro
Copy link
Contributor Author

Rebasing done on 3.x, nothing had to be changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic split screen also for 2D
3 participants