Accessing Tween

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

How do I access a tween in this garbage update?

I make a value with @onready var AimTween

set it in ready with AimTween = Node.create_tween()

But when I try to call it with AimTween.tween_property() and then AimTween.play() in another function it gives me an error

Tween invalid. Either finished or created outside scene tree.

How do I fix this so that I can call my tween in another function? This was so easy before Godot 4, I don’t understand why they felt the need to completely and totally rework tweens into something far inferior

:bust_in_silhouette: Reply From: aidave

Use this approach:

    var tween = create_tween()

    func():
        if tween:
            tween.kill() 
        tween = create_tween()
        tween.do_stuff()

Take some time to read this:

I agree they made some things about Tweens worse, especially not being able to put them in scene editor persistently and connect signals there. But they still work fine once you get the new approach