The problem is, that the first cube flips the direction, then a second cube flips it again and so on, resulting in the cubes to go back and forth.
The easiest solution is to replace the line
"If mov1\x > 3.0 Or etc"
with this:
If mov1\x > 3.9 Then direction = -0.01
If mov1\x < -3.9 Then direction = 0.01
Another approach, with a different result, is to make "direction" a field of the "mov" type. That way, each cube has it's own direction.
The easiest solution is to replace the line
"If mov1\x > 3.0 Or etc"
with this:
If mov1\x > 3.9 Then direction = -0.01
If mov1\x < -3.9 Then direction = 0.01
Another approach, with a different result, is to make "direction" a field of the "mov" type. That way, each cube has it's own direction.