0 votes


I have simple tree:


I set margins(right=512,bottom=600) of the VieportContainar to cover half of the screen. Size of viewport from the tree is 512x600. Size of main viewport is 1024x600. I attached script to Node2d in which I draw a rectangle:

extends Node2D
func draw():

I wander why this rectangle is drawn only on the area autside of aditional Viewport. How can I draw something on this aditional Viewport? How get access to the space of this Viewport to use Physics2DShapeQueryParameters. I dug through documentation, but clearly I don't understand something important.

in Engine by (22 points)

What are you trying to achieve btw?

1 Answer

0 votes

func draw() is meant to be used to create an art for a node. Like.. if you want to create sprite / texture / image for a node, you use draw(). It's called only once on the app start by default (you may force to redraw() by code if desired). It's not really meant to continuously render content.

Reason your rectangle is drawn outside of your viewport is that you call draw in you Node2D (root parent). The texture of that node is being drawn, but your viewport's camera is probably looking at empty space in your scene.

by (206 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.