0 votes

I'd like "Sprite node" to move in a direction while "Timer node" emits timeout().
How should my script look?

Node
-Timer
-Sprite

extends Node
var speed=100
var magnitude=Vector2()
var velocity=Vector2()

func _ready():
    set_fixed_process(true)

func _fixed_process(delta):
    velocity=speed*magnitude*delta
    get_node("Timer").set_wait_time(4)
    get_node("Sprite").get_pos()

func _Intro():
    magnitude=Vector2(100,0)
    get_node("Sprite").set_pos(get_pos()+velocity)

func _Timer():
    get_node("Timer").connect("timeout",self,"_Intro")
in Engine by (22 points)

while "Timer node" emits timeout?
did you mean when timeout?

1 Answer

0 votes

I do not quite understand, but I think it's something like this:

  extends Node
    var speed=100
    var magnitude=Vector2()
    var velocity=Vector2()

    func _ready():
        get_node("Timer").set_wait_time(4)
        set_fixed_process(true)

    func _fixed_process(delta):
        velocity=speed*magnitude*delta
        if get_time_left() > 0:
            func _Intro()

    func _Intro():
        magnitude=Vector2(100,0)
        get_node("Sprite").set_pos(get_pos()+velocity)

    func _Timer():
        get_node("Timer").connect("timeout",self,"_Intro")
by (201 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.