#Viewport issue

1 messages · Page 1 of 1 (latest)

long jungle
#

Hey all, I have an issue with the presence of a subviewport within my game.

Within the subviewport, I have a click and drag feature that move around the content of the subviewport. Issue is, whenever some clickable content gets out of the viewport underneath the ui around it, it still clicks the on the elements of the subviewport as if they were visible. In other words, i'm trying to make anything that gets out of the range of visibility of the subviewport non-interactive.

I'm trying to figure out a solution. My idea, so far, is to make a area2d that detects the presence of the mouse on subviewport. I would work, except I can't seem to find a way to programmatically make the area2d scale with the viewport (since the viewport size depends on screen size). I don't even see the area2d when I enable the debug visible collision shape. Here's the code for it:

func _ready():
game_data = GameData.new()
game_data.init()
money_lbl.text = "Money: " + str(money)
mouse_area_viewport.position = main_game_container.position
var new_shape = RectangleShape2D.new()
new_shape.size = main_game_container.size
print(new_shape.size)
mouse_area_viewport.shape = new_shape
_generate_new_maps()

Anyone can help?

old thicket
long jungle
#

This is the process of the game within the viewport

#

This is what the UI of the game look like right now. The right up square is the subviewport

#

It has debug -> visible collision shape enable

#

This is the node structure. If I put the area2d within the subviewport, I can see the collision layer, but it doesn't render at the right position

old thicket
# long jungle This is the process of the game within the viewport

i mean yeah that method pretty much ignores all the other logic that would automatically check if the mouse is inside the bounds of that speciffic subviewport. but for such a simple check i would just use get_viewport_rect().has_point(mouse_position), no need for an area2D.