- Home /
Remove animator component after completion / x seconds
Hi there
I'm using animation to move my player from position x to position y - unfortunately the animator component seems to be conflicting with my other components.
Ideally what I'd like to happen is to disable / remove the animator component after the animation is complete...or after x amount of seconds.
Any help would be appreciated
All the best Al
I figured it out:
using UnityEngine; using System.Collections;
public class stopAnim : $$anonymous$$onoBehaviour { private Animator selfAnim;
void Start (){
selfAnim = GetComponent<Animator>();
StartCoroutine ("waiter");
}
IEnumerator waiter(){
yield return new WaitForSeconds(3);
selfAnim.enabled = false;
}
}
Answer by terrawah · Jan 18, 2016 at 05:44 PM
Hi
As you figured out yourself, yes, to disable the animator you can set it to false. In addition, if you wanted to remove it completely, you could do
Destroy(selfAnim);
Your answer
Follow this Question
Related Questions
2D Animation does not start 1 Answer
How to change animations every 60 seconds through the animator in Unity3D and C# Visual? 1 Answer
How to detect if player hits enemy half-way into an animation? 0 Answers
How can i check if an animator has finished? 3 Answers
Move Animator to parent object 0 Answers