Hi all. This isn't much of a question as it is a knowledge transfer.

I figured out a way to call _draw functions from a singleton ('static' script / auto-loaded), so we don't have to program drawing circles, arcs and other stuff for every single node we have. We can unify it easily!

Here's my first post with the same title: https://godotforums.org/discussion/24759/calling-draw-from-another-node#latest

Here is TwistedTwigleg workaround: https://godotforums.org/discussion/comment/42967#Comment_42967

And I'll post another way to answer my own question below.

You probably have one or more singleton scripts in your game. You could dedicate one of them for drawing so you can have a unified way of drawing shapes - your style. The catch is that you can send the node itself as a parameter, and use it to draw.

Your singleton can look like this:

tool
class_name Drawer

const DRAW_DASH_LEN = 10
const DRAW_COLOR = Color.orange

func draw_circle_dashed(obj, radius: float, offset: Vector2 = Vector2.ZERO, 
	width: float = 1, antialiased: bool = false):
	for i in range(0, 360, DRAW_DASH_LEN):
		obj.draw_arc(offset, radius, deg2rad(i * DRAW_DASH_LEN), 
			deg2rad(i * DRAW_DASH_LEN + DRAW_DASH_LEN), 3, 
			DRAW_COLOR , width, antialiased)

and this is how you'd call it from ANY ONE of your nodes:

func _draw():
	if Engine.is_editor_hint():
		LevelHelper.draw_circle_dashed(self, $Area/Shape.shape.radius)

this exact function will give you a result like this one:

NOTE: - singleton has tool at di bininging so it can work with tool nodes - in any node's _draw call, if Engine.is_editor_hint(): is optional. - if you don't know about tool and Engine.is_editor_hint(), look it up, it's really useful


This method is so simple I don't know how I didn't think of it sooner!

If you've seen any other ways to use _draw calls outside the node that needs drawing, please post your answers or links to other people's answers below!

Again, take a look at TwistedTwigleg's workaround. Depending on your game one or the other implementation might be more suitable.

I hope this helps you guys. Thank you TwistedTwigleg for your support on these forums!

2 years later