Dear community,
I’ve been looking for some hours in all along relevant web resources for the following problem but with no progress …
I want to move objects along prespecified trajectories in the space. The trajectories I specify via absolute x and z coordinates (2D-trajectory), which are arranged in separated arrays. Here is my code so far. The coordinates are just examples, nevertheless, I want to have the object moving from the previous in the array coordinate point to the next one:
var x = new Array (1000, 1500, 1500, 1500, 1000, 500, 500, 500);
var z = new Array (500, 500, 1000, 1500, 1500, 1500, 1000, 500);
var cnt = x.length;
var i=0;
function Start () {
for (i=0; i<=cnt; i++) {
transform.position.x = x*;*
transform.position.z = z*;*
}
}
So, for each point to on the trajectory the machine shall iterate over all the array elements. This should give as first coordination point (according to the array above) x1z1(1000, 500), the second x2y2(1500, 500) etc.
When I run the script, however, the object doesn’t do anything. I’ve also tried it via translate.position = Vector3(x_, 0, z*) within the loop, and also here without the desired result.*
Does anybody have an idea how to approach this problem?
I thank you in advance for any help._