My script has a ball that explodes when it hits a wall, removes the ball, and plays an explosion animation (prefab), the animation plays 1 time but stays stuck on the screen. The explosion Loop Time is unchecked.
What is missing from the script to make the explosion animation disappear from the screen after playing?
The Instantiate above creates a GameObject with your effect on it. You have to destroy the object when you’re done with it. Here are the docs on Destroy:
You can even give it a delay to say “Destroy this two seconds from now.”
Instantiate returns a reference to the object it creates, and that is what you want to destroy.
Thank you but this didn’t work. I could only ‘destroy’ the ball, or ‘destroy’ the wall that was hit, but the explosion animation stays on the screen after playing. Would the animation need a blank image or an ‘end’ frame so it stops at the end of the animation?
I noticed on an existing game demo where the animation ends after playing, the animation has a blank (white diamond) at the end. How is this created? And is this the correct way to end animations?