A quick way to acess other nodes and their vars, functions and etc.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JulioYagami

I want to know if there are a way to acess other nodes and their things easily because I am very dependent of auto-completion and when I want to acess, it doesn’t appears. For example:

I have a node called cow and another called bird (cow is child of main and bird is child of tree that is child of main).


extends Node2D

var _life = 100

func _ready():
    # I need to do something?


extends Node2D

var _test = "something"

func _ready():
    # Something

Now if I want to acess one from the other and its vars and functions. What I need to do?

You can access vars with get_node(“NodePathHere”).VarNameHere pretty easily, but I don’t know about functions.

Sojan | 2018-11-26 03:14

:bust_in_silhouette: Reply From: ranjithtv

Is it okay for you to export a variable from one script and attach the required node through inspector?

export (NodePath) var cow

This works, but what about nodes instantiated by gdscript?

JulioYagami | 2018-11-27 10:20