Why does this tween have a delay even though the delay variable is set to zero?

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

Hi, I’m new to Godot and programing generally. I’m using Godot v3.2.2 and I’m try to use a basic tween to move a card in a card game from near the top of the screen to near the bottom. It works except that there is a nearly one second delay before the tween starts for some reason.

in the physics_process of the card object i have a match state set up with MOVECARD as the default state and in that state i use the tween.

func move_card_state() -> void:

tween.interpolate_property(self, "position",
	tween_start_pos, tween_end_pos, tween_duration,
	Tween.TRANS_BACK, Tween.EASE_OUT,0)

here is a gif of the result showing the delay
enter image description here

i have no idea whats wrong. Please help. Thanks for your time.

Hi, that’s odd. I think I may have had something similar, can’t remember exactly, but it may have been linked to me doing something to the Tween in the process function.
I could be way off with that though.

Have you tried printing a time when you click the card and then when the move_card_state is called, to try and work out where the delay could be?

It’s hard to tell from that code, as it works fine when I move a sprite.

Could you upload your project somewhere? Or just the bit that moves the card?

deaton64 | 2020-07-23 20:55

thanks for the suggestion. i think i found at least part of the problem but i still don’t know why.
i also have an on_tween_completed() function connected to the tween completed signal to change the card state after the tween animation is finished

func _on_Tween_completed(object: Object, key: NodePath) -> void:
state = INHAND

if i remove this connection and function and just put the change state line directly in the move_card_state() function the delay goes away.

do you know why this could be? if theres still more information needed please let me know and thanks again.

BusterDublup | 2020-07-24 02:23

yeah no idea. Hard to say without seeing the way the whole thing works.
I find printing out when things happen useful. I had an issue where an animation tween complete didn’t seem to be working. I had an alive bool setup and would call an tween when alive was set to false.
In my head, that should be fine, but because the check was in the process function, the tween was been called constantly and I could only see that when the printout was flying up the console. So I had to put an extra check in to make sure the animation was only played once.

deaton64 | 2020-07-25 09:48