Contents
How do you destroy an object after animation in unity?
You can use StateMachineBehaviour.
- In animator, select state. Game object will be destroyed after animation on that state will have finished.
- Click Add Behaviour.
- Override OnStateEnter in your script:
How do you destroy the object in DontDestroyOnLoad?
Just call destroy on it directly: Destroy(mManager); DontDestroyOnLoad only protects the object from being destroyed when loading a new scene. Thanks!
How do you destroy an object from another script?
Destroy a GameObject by using a “script” of another “GameObject”
- var go : GameObject; //Reference variable for the object you want to destroy.
- //Function to destory gameObject from the script.
- function DestroyThatObject(object : GameObject)
- {
- Destroy(object);
- }
- //Otherwise you can do this.
- go.
How to destroy object after animation in Unity?
But because you can see the shadow of that object, I will destroy it after the animation has played. But how can I do this whit Unity and C#? You could do this by checking the current state of the Animator. Add an additional state that your animation will transition to and then check if the animator reaches this state using AnimatorStateInfo.
How to delete an object after an animation?
That animation event would call a function in your goblin to delete the object. Thank you for your answer ! But I didn’t see you had the code for the death animation in your post. You keep calling it. Every time update loop, you start the dead animation.
Why do you keep calling the dead animation?
You keep calling it. Every time update loop, you start the dead animation. So as soon as your animation finish, it will start again, BEFORE checking if the animation is over. Is there a reason why you dont use the animator controller?