Anim object with Relative Position

Hello !

I want to make an animation when my ‘chess pieces’ ( is not chess piece but it is for the image ) moove. The better way is to create parent empty gameobject for each piece and assign this nice script ? unity game engine - How to make animation position start from last position - Stack Overflow

    This code solves the problem regarding animations based on last relative ImagePosition
    In this example, each time we press Fire1 a box will be animated to move from X = 0 to X = 10
    Using the animation will help us to provide richer transitions and smooth movements based on curves
    without the problem of looping

// This var will determine if the animation is started
public var animation_started : boolean = false;
// This var will determine if the animation is finished
public var animation_finished : boolean = true;

function Update () {

    // if user triggers Fire1
    if( Input.GetButtonUp('Fire1')){

        // initialize the flags
        animation_started = true;
        animation_finished = false;

        // Start the animation
        // this animation moves the box from local X = 0 to X = 10 using a curve to deaccelerate


/* This function is trigger at the end of the animation */
public function animationFinished() : void {
    animation_finished = true;

    At the end of the frame if the animation is finished
    we update the position of the parent to the last position of the child
    and set the position of the child to zero inside the parent.
function LateUpdate () {
    // if the animation is finished and it was started
    if(animation_finished && animation_started) {
        // set the flag
        animation_started = false;
        // update the parent position
        transform.parent.position = transform.position;
        // update the box position to zero inside the parent
        transform.localPosition =;

My request is simple but this solution is too ugly…
Any suggestions ?

Thank’s in advance !

Any ideas ?