0 votes

I need to know how to access a variable from another node in the scene, I have a player object that is a KinematicBody2D and a coin that is an Area2D. The coin is trying to access the variable score from the player's script. Any help would be greatly appreciated, thanks in advance!

in Engine by (12 points)

1 Answer

0 votes

You just have to find the node and then use node.variable = value

You can also use "autoload" in the autoload tab in project settings

This can let you have scene running outside the current scene, so you can find it with

onready var search_node = $"/root/scene"

This is usefull, because you can find it even if you change to another scene.

by (336 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.