This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

I created a script, blink .gd, without a scene, the essence of which is to teleport an object to the mouse

onready var _blink = preload("res://src/characters/skills/blink/").new()
func blink():

var _timer    : Timer = null
var _cooldown : bool  = false

func _init():
    _timer =
    _timer.connect("timeout", self, "_reload")

func skill(_target: KinematicBody2D) -> void:
    if !(_cooldown):
        _cooldown = true

func _reload():
    _cooldown = false

and it doesn't work. I checked timer.isconnected and it returns true.
I did something similar in scripts attached to scenes and the timer worked.

I added to code addchild(blink), and timer work, but the script no longer teleported the player.
Sorry for any mistakes, English is not my native language.

Godot version v3.5.stable.official [991bb6ac7]
in Engine by (22 points)

1 Answer

+1 vote
Best answer

Okay, I found the answer.Maybe someone will need it


really help me. I suspect this is because the timer doesn't work without an active scene attached.

by (22 points)

I have found that too. For timers to work, you need it to be part of the scene tree.

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.