Using a tween to trigger a function after X seconds...

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robster
:warning: Old Version Published before Godot 3 was released.

I am making a classic beginners mistake I know. I just don’t know what that mistake is! :slight_smile:
I want to trigger the computer’s turn after X seconds. At present it’s just too fast and I feel the player needs a bit of time to recover before the computer has its turn.

I have two functions. computersTurn() and playComputersTurn

playComputersTurn is where the real meat of the logic happens. The only reason I am using computersTurn() is to trigger playComputersTurn() after a delay. It may not be the best way but I’m only learning.

The real issue though, is getting it to work. Currently this is the code:

func computersTurn():
	tween.interpolate_callback(self, 1, "playComputersTurn()")
	tween.start()

You can see I’m trying to trigger the playComputersTurn() function after 1 second. But… It doesn’t. It doesn’t give an error, it just doesn’t happen.

Can anyone offer advice as to what I’m doing wrong? Thanks a tonne…

:bust_in_silhouette: Reply From: Robster

slaps face into hands…

OK for future reference, remove the () from the function call.

IE:

func computersTurn():
    tween.interpolate_callback(self, 1, "playComputersTurn")
    tween.start()