animation editor only record absolute position?

Hi there, when i use animation eidtor to make animation with keyframe, i found that the keyframe (position/rotation) info is absolute,eg. put a ball in the scene,and record the keyframe when the ball move from (0,0,0) to (0,0,2),

then save the animation file, make a ball prefab,next time when i instantiate a ball object, and play the animation, the ball will jump to (0,0,0),then move to (0,0,2),this is not what i want,because i want the ball move from current position(move relatively),so, how can i do this??

If you put the animated object inside an empty GameObject, it will use the parent object's coordinate space rather than world space.

Instead of using animation, you can also use scripting for this. In your example, you could use the following code (in Javascript) to make the ball move from two units along the Z axis in one frame:


This will cause the ball to move relative to its starting position. You could put this in an “Update” or “FixedUpdate” function to make the ball move continuously at a rate of two units per frame. If you use a different scripting language, I am sure you can find out the appropriate code in the Unity Scripting Reference.