-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SceneTreeTween.finished
signal is not consistent with Tween.tween_all_completed
#65645
Comments
Bug 1 (which isn't really a bug) comes from the fact that Tweens don't process together with the nodes (unlike the old Tweens). You are disabling process between frames, so the next process does not get called. Your workaround is the intended action here in this case. For 2, the first tween that finishes will stop process, so your label stops updating. If you uncomment your var tween
func animate():
if tween:
tween.kill()
tween = create_tween() EDIT: |
@KoBeWi That's what I initially suspected too but that's not the reason. In the MRP processing is disabled instantly on the finished signal so the order of tweens/nodes processing doesn't really matter here, after the signal the next It seems like the actual reason is that the 3.x
To better visualize why such behavior is wrong: if each frame would last 1 second and For @dalexeev The problem with extends Control
# warning-ignore-all: return_value_discarded
var _num := 0.0
onready var _font := get_font('font')
func _ready() -> void:
set_process(false)
func _process(_delta: float) -> void:
update()
if not tween.is_running():
set_process(false)
func _draw() -> void:
draw_string(_font, Vector2(), '%.3f' % _num)
func _input(event: InputEvent) -> void:
if event.is_action_pressed('ui_down'):
animate(-10.0)
if event.is_action_pressed('ui_up'):
animate(10.0)
var tween := SceneTreeTween.new()
func animate(to: float) -> void:
set_process(true)
if tween.is_running():
tween.kill()
tween = create_tween()
tween.tween_property(self, '_num', to, 2.0) @KoBeWi Regarding the documentation it might be a good idea to mention somewhere that SceneTreeTweens/SceneTreeTimers are processed after nodes' |
Thank you. It seems to me that this should be mentioned in the description of the signal, although this does not apply directly to it (it should always be taken into account when working with As for the new |
Godot version
v3.5.stable.official [991bb6a], v4.0.alpha.custom_build [4610372]
System information
Kubuntu 22.04
Issue description
Bug 1:
Press the Up or Down key and wait. The
finished
signal may be emitted before the displayed value reaches 10 or -10. At the same time, an additionalupdate
/queue_redraw
allows you to workaround the bug. That is, the bug is not thatTween
does not bring the value to the end, but that it reports this too early (in the wrong frame).This bug is unstable, in some cases it is reproducible, in others it is not. For me, it is almost always reproduced for the first time, then it is not reproduced, then it can appear again.
Old 3.x
Tween
does not have this bug,tween_all_completed
is always emitted after the visible value has become correct.Bug 2 (need a separate discussion?):
(Found by accident while testing MRP for Bug 1. So some of the things below are not quite correct, the asynchronous approach for this task works with the old
Tween
, but does not work with the new one. Need to implement it somehow differently.)Press the Up and Down buttons alternately to keep the value around 0, preventing it from reaching 10 or -10.
In the case of the old
Tween
, this will work, since there is only oneTween
node, and new calls tointerpolate_property
will override the old ones. You can keep the value around 0 for as long as you like, and thetween_all_completed
signal will only be emitted once when the variable's value reaches 10 or -10 (multiple console messages because multiple asynchronous calls continued waiting for the same signal).Something strange is happening in the case of the new
Tween
.We no longer have a single
Tween
node, but multipleTween
objects created each time theanimate
is called. The newTween
is designed for a "create and use" approach, it's not entirely clear how to use it in this case (put it in a class member?). There was an issue recently that raised a similar question (aboutTween
's lifetime, and that it is invalidated when the animation finishes).Is it acceptable to have multiple instances of
Tween
animate the same property of the same object? Now something strange is displayed in the console: alternately 10 and -10, although the value should always stay somewhere around 0 (apparently, each instance ofTween
operates with its own copy of the value).Steps to reproduce
See above.
Minimal reproduction project
tween_3.5.zip
tween_4.0.zip
The text was updated successfully, but these errors were encountered: