First of all, nice lorry (slow-clap).
Here's how to make it drive forward along the x axis. You could add a Y-component of motion very easily.
maxX = 35;
stepSize = 0.2;
arrived = false;
while ~arrived
lorry(1).Vertices(:,1) = lorry(1).Vertices(:,1) + stepSize;
lorry(2).Vertices(:,1) = lorry(2).Vertices(:,1) + stepSize;
lorry(3).XData = lorry(3).XData + stepSize;
lorry(4).XData = lorry(4).XData + stepSize;
lorry(5).XData = lorry(5).XData + stepSize;
lorry(6).XData = lorry(6).XData + stepSize;
drawnow()
arrived = max(lorry(2).Vertices(:,1)) + stepSize > maxX;
end
Best Answer