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.
0 votes

I wrote a script to spawn nodes for my game and this game is an endless runner so I want to move my nodes into a specific direction.

func spawn():
    var energy_scene = load("res://scenes/energy.tscn")
    var energy = energy_scene.instance()
    var random = Vector2(rand_range(30,230),30)

    #energy.set_position(Vector2(random.x,500)) --> but it goes directly to that location without speed, without animation
in Engine by (62 points)

1 Answer

+1 vote
Best answer

You can use a Tween

You can either add a Tween node to your scene tree, or create one manually. Either way, you can then do something like:

    energy, // node to operate on
    "position",  // property to change
    random, // initial value
    Vector2(random.x,500), // final value
    1, // duration, in seconds
    Tween.TRANS_LINEAR, // interpolation function, see
    Tween.EASE_IN, // easing function, see
    0, delay, in seconds
by (1,663 points)
selected by

thanks that will do the work

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.