godot: Error message `step: : started with no Tweeners` missing essential information

Godot version

v4.1.rc2.mono.official [46424488e]

System information

Linux

Issue description

Getting error message at runtime. The error message does not show what is the origin of this error.

E 0:00:36:0394   step: <Tween#-9223371483558965298>: started with no Tweeners.
  <C++ Error>    Method/function failed. Returning: false
  <C++ Source>   scene/animation/tween.cpp:311 @ step()

Expected behaviour would be to have error message show which tween, meaning, which .gd script line that is attempting to start a tween that is not created. So that it is easier to fix the issue. Now I would have to go through all tweens in the game.

Steps to reproduce

Not sure if that is required to fix the issue by providing more information in error message, to allow for tracking it to specific origin of the call.

Minimal reproduction project

none

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 2
  • Comments: 27 (14 by maintainers)

Commits related to this issue

Most upvoted comments

How would you suggest an improvement? What beyond “they start automatically” would be needed here in your opinion?

Well, you can manually call play() to start a Tween, in which case the error could be tracked (not tested). The Tweens that start automatically do so from C++ code, you can see the C++ line in the error.

The two correct usages are: Create, stop, use later and call play

Actually it’s not exactly correct. Tweens are heavily encouraged to be setup immediately on create and never reused (#74258). The code might be valid, but doesn’t make much practical sense.

Although we recently had a discussion to maybe allow re-using Tweens. While the is no real performance gain, it can sometimes save a bit of boilerplate code. The create_tween() function would get an autostart argument to make it easier. But it was only discussed, no decision was made so far (and there is no proposal).

Your usage of tween_method() is wrong and it causes invalid Tweener. You should be getting another error about it.

Tweens are not designed for reusing. The documentation warns about that and none of the examples point to creating a Tween with intention of later usage. The example you suggested actually existed until #74258

Leave it open to discuss the documentation, we don’t have triage meetings 😃

Getting somewhat of topic here though

I was responding to above. Sorry it that was unclear. Thank you I will comment on the suggested proposal in regards to alternative pattern for not reusing the tweens.

In regards to this issue. Can I close it with comment that documentation could possibly be improved, or shall I leave to some triage meeting, or leave as is ?

How would you suggest an improvement? What beyond “they start automatically” would be needed here in your opinion?

For example just to add something like: If you are not planning to use the tween immediately withing the scope call .stop() when initialising.

@onready tween: Tween = get_tree().create_tween().stop()

otherwise you might see an error like:

E 0:00:36:0394   step: <Tween#-9223371483558965298>: started with no Tweeners.
  <C++ Error>    Method/function failed. Returning: false
  <C++ Source>   scene/animation/tween.cpp:311 @ step()

Yes, the tween starts automatically, so just creating it and not initializing it is incorrect

Is this consistent with other objects in Godot ? Does it need any additional documentation ?

Not sure that

A Tween can be created by using either [SceneTree.create_tween](https://docs.godotengine.org/en/stable/classes/class_scenetree.html#class-scenetree-method-create-tween) or [Node.create_tween](https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-method-create-tween). Tweens created manually (i.e. by using Tween.new()) are invalid and can't be used for tweening values.

And

Note: All Tweens will automatically start by default. To prevent a Tween from autostarting, you can call [stop](https://docs.godotengine.org/en/stable/classes/class_tween.html#class-tween-method-stop) immediately after it is created.

in class_tween-docs

Actually indicates that creating and not using is incorrect. From what I can understand it says, use SceneTree.create_tween to create and call stop to prevent it from starting automatically.

Ok so in my case the error message was caused by having

@onready var highligt_tween: Tween = get_tree().create_tween()

At the scope of GDscript class that was used by the Node2D scene. It seems to be fine when the variable is only defined

@onready var highligt_tween: Tween

But causes same error message when trying to init the tween in

func _ready():
	highligt_tween = get_tree().create_tween()

and not using it in the _ready but later in other functions in that same class.

Is this even supported use case to have tweens created in _ready() and then reused throughout the functions ?