Anim8or Community

General Category => ASL Scripts => Topic started by: klavan on October 10, 2008, 09:30:49 pm

Title: data storage in/during controller scripts
Post by: klavan on October 10, 2008, 09:30:49 pm
is it possible to calculate the speed of a moving element in a controller script? There is no data storage between scripts so you don't know e.g. the element's position in the previous frame.....

Thanx
Title: Re: data storage in/during controller scripts
Post by: NickE on October 10, 2008, 10:33:30 pm
You can access an element's position and orientation for each frame from a script.  You can create a dummy element to hold values between frames.  Between these two things, you can calculate rotational and translational velocities and acceleration.

It would be helpful if you could describe what you are trying to do.   There are techniques for reading the position of one element to set the other.  For example, one can use a controller script to control the rotation of tires, another script to move the vehicle proportionally to the rotation of the car, and yet another to move the camera with the car, and so on.
Title: Re: data storage in/during controller scripts
Post by: Steve on October 12, 2008, 10:00:07 pm
There aren't any ways to read data in a controller other that values of the current frame.  If one frame depended on another's values it would allow computations that wouldn't evaluate to the same value each time they were executed.  Anim8or can evaluate key values an unexpected times.  This could make your animation behave differently each time and even make single frames move about chaotically.
Title: Re: data storage in/during controller scripts
Post by: hf003 on April 25, 2010, 10:22:26 pm
I am a bit confused as to why you say there would be unpredictable outcomes if we used information of previous frames to compute new values in the current frame. It seems to me if the initial conditions and computation are always the same, the outcome would always be the same as well. For instance, if we could set the initial position of an object to 0,0,0, then in a position controller script set the object's X position of the current frame to the position of the previous frame's X position+1. How would the outcome be different each time the scene is played? At frame 10, the objects position should always be 10,0,0. Maybe Steve or someone can elaborate on this example to show what I am missing. It seems it would make animation easier in some cases if information of at least the previous frame's object parameters were known to the current frame's script.