Completion callback in gui.animate called too early (SOLVED)

When animating a vector property using gui.animate, the callback appears to be called just after updating the first component.

function init(self)
	self.node = gui.get_node("test")
	gui.animate(self.node, "position", vmath.vector3(200, 200, 1), go.EASING_LINEAR, 1, 1, function()
		print("Position during callback " .. gui.get_position(self.node))
	end)
end

function update(self, dt)
	print(gui.get_position(self.node))
end

DEBUG:SCRIPT: vmath.vector3(193.33322143555, 193.33322143555, 0.96666610240936)
DEBUG:SCRIPT: vmath.vector3(196.66654968262, 196.66654968262, 0.98333275318146)
DEBUG:SCRIPT: Position during callback [200.000000, 196.666550, 0.983333]
DEBUG:SCRIPT: vmath.vector3(200, 200, 1)
DEBUG:SCRIPT: vmath.vector3(200, 200, 1)

I got similar results with scale and color. Works fine in go.animate.

4 Likes

Hi Rafael!
We just found this last week as well, we have the Jira ticket DEF-1972 for this.
Your observation that it works with go.animate() is a nice clue. Thx!

1 Like

Hello @Mathias_Westerdahl ,

Is this a 1.2.86 thing or is there any progress about this situation, I just realized that my gui elements hanged out around screen. So much code relied on this feature.

DEBUG:SCRIPT: vmath.vector3(800, 0, 0) – from position
DEBUG:SCRIPT: vmath.vector3(800, -925, 0) – To position
DEBUG:SCRIPT: vmath.vector3(800, -786.65252685547, 0) --animation finished position

I didn’t test go.animate .

Best Regards,

Hi @ArmandCloud.
No that issue hasn’t been fixed yet I’m afraid.
In the meantime, a workaround could perhaps be to set the “to” value inside the completed callback, once the x-component has finished the animation.

1 Like

This should be fixed in the latest stable (1.2.94): Defold 1.2.94 has been released

Marking it as solved! :slight_smile:

3 Likes

Thanks for the heads up @sven ,

Huge step for man kind on defold planet.

Best Regards,

2 Likes