Having troubles with a script controller working properly.
I'm a bit of a novice, in fact I haven't really wrote any scripts before this point. I was tasked with making a plane rotate to face the camera and for it to change it's texture based on which direction the camera is facing it in relation to it's direction. This is for a scene with background people placed on planes. The people will be facing a certain direction, for example north, but the alpha plane needs to always face the camera and the textures will change based on that. So you swing around from the person's front side to the back it'll swap the texture as needed. Make sense?
Now, I wrote all of this and it sort of works, but I have a couple issues and one very big issue. It should be noted that I can't use the lookat constraint controller for the rotation. The card has to be a single object I can place in any scene and it'll automatically look at the current camera or perspective view.
My code looks a little like this. It's a little sloppy, but it works in the viewport without to much issue. The big problem is that when I go to hit render it wont evaluate the script for each frame so when I render it doesn't actually work. If I move the time slider in max back and forth though it'll update.
So I'm getting the viewport information to see where the camera is in space. Then I'm constructing a right triangle based on it's x and y position in relation to the plane. Finally I use that to figure out the degrees that the object needs to turn to face the camera.
cameraTM = Inverse(viewport.getTM())
AJD = cameraTM.row4.x - self.pos.x
OPP = cameraTM.row4.y - self.pos.y
HYP = sqrt((AJD^2)+(OPP^2))
Degrees = (acos (AJD/HYP))
Radians = degrees*(pi/180)+NT
if (coordSysTM.row4.y > self.pos.y) then Radians