if message_id == hash("work")
then
qwe = gui.get_position(self.blue_fills[10])
dt = 10
gui.animate(self.blue_fills[1], gui.PROP_POSITION, vmath.vector3(qwe.x, qwe.y + 20, qwe.z), gui.EASING_INOUTSINE, dt)
qwer = gui.get_position(self.blue_fills[1])
pprint(qwer)
end
When I send “work” first time qwer returns vmath.vector3(895.71166992188, 275.5192565918, 0) and if i send “work” again qwer returns vmath.vector3(895.71166992188, 439.5192565918, 0).
How can I receive correct coordinate of Nodes after gui.animation
I need to receive vmath.vector3(895.71166992188, 439.5192565918, 0) after animation.
But I receive correct position only after second message. I want to receive it on first message
The execution of code after your call to go.animate() will not wait until the animation is done. When you call go.animate() the animation will start and the code will continue to execute and you’ll still read the original position. You need to use the go.animate() callback function:
if message_id == hash("work") then
local qwe = gui.get_position(self.blue_fills[10])
local dt = 10
gui.animate(self.blue_fills[1], gui.PROP_POSITION, vmath.vector3(qwe.x, qwe.y + 20, qwe.z), gui.EASING_INOUTSINE, dt, 0, function()
local qwer = gui.get_position(self.blue_fills[1])
pprint(qwer)
end)
end
PS. I added the local keyword in front of some of your variable declarations. If you don’t the variables will become global and it can result in unwanted side effects.