Timer is a null instance.

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

So I’ve been having some trouble starting a timer, due to it being a null instance for some reason. I have no idea what’s wrong. I’ve tried attaching it to a variable and printing said variable every idle frame; sometimes it shows the timer, other times it says that it’s null. Everything looks right in the code, so I don’t know what the issue is. Any help would be appreciated.

My Variables:
Imgur

The Code:
Imgur

The Code, but without the variable, just the node name:
Imgur

The Node Structure:
Imgur

The Print Results:
Imgur

Try something simple: on a button press (cancel, enter, whatever), start the timer, on another button press, print the timer, nothing else.

I see you’ve set up attacktimer and swingtimer, so experiment making both start() on that above situation, then print. Something like this on the print should help you out:

if Input.is_action_just_pressed("ui_cancel"): 
   print(attacktimer.is_stopped, " - ", attacktimer.time_left)
   attacktimer.start() #forces a restart after printing the previous result

MisterMano | 2021-10-30 02:27

Hey, sorry for the late response. Didn’t seem to work, still shows as a null instance.

Results:
Imgur: The magic of the Internet

OiKeTTLe | 2021-10-31 00:56

:bust_in_silhouette: Reply From: Inces

Ok, I saw it in other thread, it is really weird :slight_smile:

Why print results show timers with two different IDs, aside form null objects ? You said You only printed 1 variable - attacktimer ?
Is it really whole code ? Is there nothing in autoload or parent node that can alter behavior of this sword node?