How i can make this glitch effect smoother?

Hi!

I’m trying to create a glitch effect with a label.

Here’s my code:

function init(self)
	go.animate("child", "position.x", go.PLAYBACK_LOOP_FORWARD, 500, go.EASING_LINEAR, 4)
	go.animate("child", "position.y", go.PLAYBACK_LOOP_FORWARD, -500, go.EASING_LINEAR, 2)
	for i = 1,16 do
		timer.delay(i/16, true, function() local dude = go.get_position("child") go.set_position(vmath.vector3(dude.x, dude.y, 0.001), "child"..i) end)
	end
end

And here’s what it looks like.

Hopefully the problem is clear: I want a more regular glitch effecting where the distance between each instance of the label is the same.

Any help?

… okay, it is clear something is wrong with the timer. Printing i within the callback section gives me this miss:

DEBUG:SCRIPT: 3
DEBUG:SCRIPT: 1
DEBUG:SCRIPT: 5
DEBUG:SCRIPT: 10
DEBUG:SCRIPT: 1
DEBUG:SCRIPT: 2
DEBUG:SCRIPT: 4
DEBUG:SCRIPT: 7
DEBUG:SCRIPT: 1
DEBUG:SCRIPT: 3
DEBUG:SCRIPT: 11
DEBUG:SCRIPT: 1
DEBUG:SCRIPT: 2
DEBUG:SCRIPT: 1

Are those the first 16 output lines?

I assume it’s not, since you have repeating timers, at different intervals: 1/16, 2/16 and so on.

I have more-or-less solved this by just having 16 go.animate()s, each with a slight delay.

But no, those are not the first 16 lines. But shouldn’t the output stay regular all the time (…and follow the same order: 1, 2, 3 etc on a loop?)

1 Like

…okay, I just realised how stupid this mistake was. I only need one timer, and I should put the “for i = 1,16” in the callback.

I guess I just needed to sleep on it. I’ll fix this later this morning. Thanks for your input Mathias!

2 Likes

No, not if you tell them to trigger on different intervals.

now THAT is smooth!

nb. mathias thanks for helping me with this despite the fact that it was glaring obvious

6 Likes

more synced faux 3D text work right here!

4 Likes