0 votes

i wanted to see where the hidden node position while play in the editor

in Engine by (73 points)
edited by

I'm not sure if I understand you correctly: You have a a node, that is hidden, but if you run the game you want to be able to see it's bounding box nonetheless? Why?

i want to make sure the node position are correct in it places, before it switch to appear again

something like turn on visible collision shape on the debug

well, this isn't so important right now, as we already solved why there is 4 pixel excess on the vboxcontainer on the column of control node, turn out it need to use custom constant - separation by 0

1 Answer

0 votes

I still don't see why you can't simply call show() on your node, if you want to find out where it is. Seems like reinventing the wheel to me... Anyways: there is no option for that. But if you really want this, you can write some _draw-code to do it for you.

Because parent-nodes are drawn before their children, you cannot put that code to the parent node though. And because _draw-calls are ignored when the node they belong to isn't visible, you also cannot attach it to the node in question itself.

So if your tree looks like this:

- Root-Node
  - "Node1" (any Control-Node, this is the hidden one)

You want to add a second child in the end:

- Root-Node
  - "Node1" (any Control-Node, this is the hidden one)
  - "Node2" (any CanvasItem-Node, this is our drawing helper)

And then you can attach the following script to "Node2":

extends Control

func _draw():
    draw_rect(get_node("../Node1").get_rect(), "#FF0000", false)

If "Node1" is not a Control-node, there won't be a get_rect()-function and you have to derive the dimensions yourself using the position- and size-properties. "Node2" has to be a CanvasItem or there won't be a _draw-function to override. If "Node1" is moving during runtime, you have to call the update()-function on "Node2".

by (10,469 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 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 webmaster@godotengine.org with your username.