This content has been marked as final. Show 3 replies
Let's break this down into steps.
To use interpolate() you need two transforms: the transform of the model before it moves and a transform representing its position at the end of its move. Suppose myObject is a pointer to the object you want to rotate. Suppose myTarget is a pointer to the object that you want myObject to point at. You can obtain these two transforms as follows:
myStartTransform = myObject.transform.duplicate()
myEndTransform = myObject.transform.duplicate()
Now you simply need to perform the interpolation between these two transforms, and set the transform of myObject to the result. So long as there is no update between the lines above and the first interpolation, the user will never see that myObject rotated momentarily to its end position.
Is there something special to think of when interpolating an object two times? As it is now I have put the rotation interpolation and the movement interpolation in the same handler, and it seems as they don't work together just like that. Should I put them in separate handlers or something? Now they are both called on exitframe. Thanks for all your help.
When you use interpolate(), Director chooses shortest path. This may not be the most natural. If you need more precise control of the movement, then I think that you will need to come to terms with the 3D mathematics involved, and build the animation yourself.
It sounds that you are trying to get the object to travel along the direction in which it is facing, so that it arrives at its end point after describing a curve. It would be much easier to make the object rotate on the spot, then travel in a straight line (think RoboCop). The more complex alternative is to precalculate the curve, say using a bezier, then work out on each frame how far the object will have travelled along the curve, and so what its new rotation and position will be.
Here are a couple of examples of pre-calculated Lingo-controlled animations: Light a match and Fold a mesh