- Home /
Question by
Coreyf716 · Oct 26, 2012 at 10:00 PM ·
animationgameobjectparentclip
Play Animation Clips Not Attached to Parent?
How can an animation clip be played that is not attached to the parent object of the script that plays it?
Comment
Best Answer
Answer by spiceboy9994 · Oct 26, 2012 at 11:05 PM
You can do GameObject.Find("YourGameObject").animation.Play("animationName");
Or better you could cache your object
private GameObject myAnimatedObject;
void Start()
{
myAnimatedObject = GameObject.Find("myObjectToAnimate");
}
void AnimateExternalObject()
{
myAnimatedObject.animation.Play("animationName");
}
Hope this helps.