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

Global mouse position is messed up when viewport is changed during runtime #1

Open
Ezenki opened this issue Feb 22, 2021 · 6 comments

Comments

@Ezenki
Copy link

Ezenki commented Feb 22, 2021

Whenever I change the size of the viewport during gameplay, the global mouse position in messed up and the engine cant calculate it correctly, is presume this is because the split-screen functionality of the code doesn't account for viewport changes during runtime.

@jocamar
Copy link
Owner

jocamar commented Feb 22, 2021

When you say changing the size of the viewport do you mean resizing the game window or changing the size property of the viewport in player_viewport.tscn?

@Ezenki
Copy link
Author

Ezenki commented Feb 23, 2021

When I resize the game window

@jocamar
Copy link
Owner

jocamar commented Feb 23, 2021

Hmm, it might be related to this issue in Godot:
godotengine/godot#34805

I don't do anything too fancy with split-screen so I think this is probably a problem with using Viewports in Godot. Do any of the solutions in the issue above work for you?

@Ezenki
Copy link
Author

Ezenki commented Feb 23, 2021

Does the game manager have a way to get viewport rect size to use for a clamp function, because when I use the built-in get_viewport_rect().size, the character still walks past the boundary on the right and bottom parts of the screen

@jocamar
Copy link
Owner

jocamar commented Feb 23, 2021

You should be able to get the size of the viewport by calling get_viewport().get_visible_rect(). But I can add a method to get you the viewport reference so you can call any viewport methods for each viewport.

@Ezenki
Copy link
Author

Ezenki commented Feb 23, 2021

yeah, a method to call viewports would be nice, I had to work around the clamp problem by just changing the size of the player viewport scene to match my project settings.

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

No branches or pull requests

2 participants