kajal
kajal

Reputation: 13

How to set position of gameobject for animation in script

I have two game object. Both gameobject positions are different... I attached same animation clip to both gameobject.

In one game object I am don't want any change in animation clip. I just want to use same animation clip on different gameobject but animation timing is different & In other Gameobject I am just want to play animation at 0.30 s but I not knowing how set position of this gameobject in script.

I am assign below script to second game object.

using UnityEngine;
using System.Collections;

public class ani3 : MonoBehaviour {

void Start () {

        animation ["@cube"].time = 0.30f;
        //how to set position of gameobjet

    }
void Update () {
gameObject.animation.Play("@cube");
}
}

Upvotes: 1

Views: 954

Answers (1)

Muhammed Albarmavi
Muhammed Albarmavi

Reputation: 24424

you can use a empty game object and nest one of the game object as child and change the position of the empty game object ,it is work for me.

Upvotes: 1

Related Questions