I have a scene with a cylinder with it's position (but not angle) constrained to a path. I'm trying to control the tangency of the cylinder with this script:
var x1 = GetValue("cylinder.kine.global.posx");
var z1 = GetValue("cylinder.kine.global.posz");
var time = GetValue("TimeSet.Frame");
time++;
var x2 = GetValue("cylinder.kine.global.posx", time);
var z2 = GetValue("cylinder.kine.global.posz", time);
Out.Value = Math.atan( (x1-x2) / (z1-z2) ) * 57.295 + 90;
But it doesn't work. I tried following the variables with logmessages, and it appears that the time difference is not evaluated at all, x1 has the same value as x2, same for z1 and z2.
Now next I move the same script to the Script Editor for debugging, and change the last line to this:
SetValue("cylinder.kine.local.roty", Math.atan( (x1-x2) / (z1-z2) ) * 57.295 + 90);
And suddenly it works! Why does the time offset work in the Script Editor but not the Animation Editor Scripted Operator?? I also tried doing the SetValue in the Scripted Operator instead of the Out.Value, but to no effect.
I'm very much starting to get fed up with XSI scripting. Here the same global script gets different behavior depending on where it's run, and in another scene I get Huge memory leaks. Is it really this buggy? Is there ANY decent documentation anywhere, or are we supposed to guess everything? Does anybody have a clue about why this doesn't work?
(TimeSet is my own custom parameter set belonging to the scene root, which has a parameter called Frame, which gives the current frame number via an expression. I looked and looked but found no information on how to directly access the current frame number. I'd really like some kind of documentation here)