Can't access Timer object in _process function

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

the node is a child of root node, and it has a child Timer node, script attached to the node is like

onready var timer = get_node("Timer")

func _ready():

func _process(delta):

But there is more code in the scene. So when I run the scene, it print [Timer:1017], should be from the _ready function, and all it print then is [Deleted Object], the code is why the timer got deleted?
I create a separate scene and only contain these code and it work, but no idea why this happened.

Can you post the full script? If it works when the code above is the only code… it sounds like something elsewhere in the script could be interfering with it.

i_love_godot | 2019-01-27 13:03

Thanks for your reply, I have found the answer. In my _ready function I have lines like these:

for child in get_children():

I just want to clear other tile didn’t meet the condition and regenerate. And so it freed all the child I added to the node. What I need to do is find the exact objects I want to free and free them.

hsjaaa | 2019-01-27 13:23