- Home /
Change iTweenPath Nodes Positions From Script
I have tried below code, but the nodes positions do not change:
var itweenpath : iTweenPath;
itweenpath = Camera.main.GetComponent(iTweenPath);
for(var z : int = 0; z < 4; z += 1)
{
itweenpath.nodes[z].y = 100; // I tried to change the nodes' y position to 100 here.
print(itweenpath.nodes[z].y); // Prints out the original y position, instead of 100. Also no change in the game.
}
Please help me!
Comment
Best Answer
Answer by whydoidoit · Jun 24, 2012 at 11:31 AM
Your problem is that a Vector3 is a struct and its value is copied when you get it, so you can't just do what you are there, you are modifying the copy which is then lost.
Instead:
var pos = itweenpath.nodes[z];
pos.y = 100;
itweenpath.nodes[z] = pos;