0 votes

I'm trying to access a timer, but get_node() can't find my object.

Here is my code:

onready var timer = get_node("/root/Main/Timer")
My path is:

Main

------Gun

------Timer

Just know that I'm new to Godot.

Godot version 3.4.4
in Engine by (14 points)

1 Answer

0 votes

What script are you calling "get_node" from? Your syntax appears to be correct.

One possible explanation for your problem is that you're calling getnode before the timer has been initialized in the SceneTree. Knowing more about where "getnode" is being called from could help troubleshoot that possibility.

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