Chaining two moveLinear calls on the same object

I have a simple problem:
When I chain two moveLinear calls on the same object in a row, the object moves at a diagonal to the two separate instructions and just keeps going

function mov_n8() {
andy.moveLinear(n8coord.x, n8coord.y, n8coord.z, 5);
}

function mov_n8_n1() {
andy.moveLinear(n1coord.x, n1coord.y, n1coord.z, 6);
}

Essentially, I want the second movement block to wait until the first movement block finishes the animation and it currently is not.

Hi,

You need to use callback functions in this case:

andy.moveLinear(n8coord.x, n8coord.y, n8coord.z, 5, function() {
    andy.moveLinear(n1coord.x, n1coord.y, n1coord.z, 6);
});

The second call will be performed when the first call finishes.

2 Likes