Go.animate('#sprite','tint',...) bug (DEF-2095)

Sometimes newly created game object to animate the ‘tint’ is not work:

go.animate('#sprite', 'tint', go.PLAYBACK_ONCE_PINGPONG, vmath.vector4(1, 1, 1, 1), go.EASING_LINEAR, 0.4, 0, on_ani_done)

So I add debug output to update function:

print(go.get('#sprite', 'tint'), msg.url('#sprite'))

I found that on_ani_done is called, but the tint is not changed.

Note that [test:/instance76#sprite] worked ok, but other instance’s tint was not changed.

Thanks for reporting! Could you share some more info on how you set it up? I could not reproduce this when I tested with 4 spawned instances.

test.collection [used as main collection]

  • go [gameobject]
  • factory [points to spawn.go]
  • script [test.script]

spawn.go

  • script [spawn.script]
  • sprite

test.script

function init(self)
	for i=1,4 do
		local x = math.random() * 600
		local y = math.random() * 400
		factory.create("#factory", vmath.vector3(x, y, 0.0), vmath.quat(), {}, vmath.vector3(0.1, 0.1, 0.1))
	end
end
local function on_ani_done()
	print("Done")
end

function init(self)
	go.animate('#sprite', 'tint', go.PLAYBACK_ONCE_PINGPONG, vmath.vector4(0, 0, 1, 1), go.EASING_LINEAR, 4, 0, on_ani_done)
end

function update(self, dt)
	print(go.get('#sprite', 'tint'), msg.url('#sprite'))
end
DEBUG:SCRIPT: vmath.vector4(1, 1, 1, 1)	url: [default:/instance0#sprite]
DEBUG:SCRIPT: vmath.vector4(1, 1, 1, 1)	url: [default:/instance1#sprite]
DEBUG:SCRIPT: vmath.vector4(1, 1, 1, 1)	url: [default:/instance2#sprite]
DEBUG:SCRIPT: vmath.vector4(1, 1, 1, 1)	url: [default:/instance3#sprite]
DEBUG:SCRIPT: vmath.vector4(0.99166667461395, 0.99166667461395, 1, 1)	url: [default:/instance0#sprite]
DEBUG:SCRIPT: vmath.vector4(0.99166667461395, 0.99166667461395, 1, 1)	url: [default:/instance1#sprite]
DEBUG:SCRIPT: vmath.vector4(0.99166667461395, 0.99166667461395, 1, 1)	url: [default:/instance2#sprite]
DEBUG:SCRIPT: vmath.vector4(0.99166667461395, 0.99166667461395, 1, 1)	url: [default:/instance3#sprite]
DEBUG:SCRIPT: vmath.vector4(0.98333334922791, 0.98333334922791, 1, 1)	url: [default:/instance0#sprite]
DEBUG:SCRIPT: vmath.vector4(0.98333334922791, 0.98333334922791, 1, 1)	url: [default:/instance1#sprite]
DEBUG:SCRIPT: vmath.vector4(0.98333334922791, 0.98333334922791, 1, 1)	url: [default:/instance2#sprite]
DEBUG:SCRIPT: vmath.vector4(0.98333334922791, 0.98333334922791, 1, 1)	url: [default:/instance3#sprite]
DEBUG:SCRIPT: vmath.vector4(0.97500002384186, 0.97500002384186, 1, 1)	url: [default:/instance0#sprite]
DEBUG:SCRIPT: vmath.vector4(0.97500002384186, 0.97500002384186, 1, 1)	url: [default:/instance1#sprite]
DEBUG:SCRIPT: vmath.vector4(0.97500002384186, 0.97500002384186, 1, 1)	url: [default:/instance2#sprite]
DEBUG:SCRIPT: vmath.vector4(0.97500002384186, 0.97500002384186, 1, 1)	url: [default:/instance3#sprite]
1 Like

You actually can animate them simultaneously.

1 Like

I was seeing this earlier with my project as well. I don’t think it is a problem with animate however, as I was just setting the tint. I thought my issue was related to some depth problem (as randomly changing depths seemed to make the problem go away), but seeing this bug report means it is probably related to the tint not actually getting set.

I found the test case:

  • change the hint in sprite obj init
  • create a sprite obj after delete other sprite obj instance at once

test.script

function init(self)
    local obj1 = factory.create('#factory', vmath.vector3(200, 200, 0), nil, {}, 1)
    go.delete(obj1)

    local obj2 = factory.create('#factory', vmath.vector3(200, 200, 0), nil, {}, 1)
    msg.post(obj2, 'play_ani')
end

spawn.script

function init(self)
    go.set('#sprite', 'tint', vmath.vector4(1,0,0,1))
end

function update(self, dt)
    if self.is_animating then
        print(go.get('#sprite', 'tint'))
    end
end

local function on_ani_done(self)
    self.is_animating = false
end

function on_message(self, message_id, message, sender)
    if message_id == hash('play_ani') then
        self.is_animating = true
        go.animate('#sprite', 'tint', go.PLAYBACK_ONCE_PINGPONG, vmath.vector4(0, 0, 0, 1), go.EASING_LINEAR, 0.4, 0, on_ani_done)
    end
end

and the console output:

DEBUG:SCRIPT: vmath.vector4(1, 0, 0, 1)
DEBUG:SCRIPT: vmath.vector4(0.91666668653488, 0, 0, 1)
DEBUG:SCRIPT: vmath.vector4(0.91666668653488, 0, 0, 1)
DEBUG:SCRIPT: vmath.vector4(0.91666668653488, 0, 0, 1)
DEBUG:SCRIPT: vmath.vector4(0.91666668653488, 0, 0, 1)
DEBUG:SCRIPT: vmath.vector4(0.91666668653488, 0, 0, 1)
DEBUG:SCRIPT: vmath.vector4(0.91666668653488, 0, 0, 1)
DEBUG:SCRIPT: vmath.vector4(0.91666668653488, 0, 0, 1)
DEBUG:SCRIPT: vmath.vector4(0.91666668653488, 0, 0, 1)
DEBUG:SCRIPT: vmath.vector4(0.91666668653488, 0, 0, 1)

Excellent, thanks for the repro case! This is most likely a wider issue than just the tint and should be easy to fix now.

1 Like

Indeed. I’ve created a ticket DEF-2095 and created a repro case here https://github.com/britzl/publicexamples/tree/DEF-2095/examples/DEF-2095

The interesting thing is if I spawn more than two game objects it will only be the most recently created game object that is affected. The rest of them will have their tint modified as expected. I also tried it when animating position and that worked as expected. Doing the same with sprite scale also works.

1 Like