- Home /
what to do to get the explosion animation of an object
what to do to get the explosion animation of an object I would like the elements that are in the scene after winning a round to disappear with the explosion animation. this is the script for the whole game:
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
[RequireComponent(typeof(GameUI))]
public class GameController : MonoBehaviour
{
public static GameController Instance { get; private set; }
[SerializeField]
private int knifeCount;
[Header("Knife Spawning")]
[SerializeField]
private Vector2 knifeSpawnPosition;
[SerializeField]
private GameObject knifeObject;
public GameUI GameUI { get; private set; }
private void Awake()
{
Instance = this;
GameUI = GetComponent<GameUI>();
}
private void Start()
{
GameUI.SetInitialDisplayedKnifeCount(knifeCount);
SpawnKnife();
}
public void OnSuccessfulKnifeHit()
{
if (knifeCount > 0)
{
SpawnKnife();
}
else
{
StartGameOverSequence(true);
}
}
private void SpawnKnife()
{
knifeCount--;
Instantiate(knifeObject, knifeSpawnPosition, Quaternion.identity);
}
public void StartGameOverSequence(bool win)
{
StartCoroutine("GameOverSequenceCoroutine", win);
}
public AudioClip impact6;
private IEnumerator GameOverSequenceCoroutine(bool win)
{
if (win)
{
AudioSource.PlayClipAtPoint(impact6, transform.position);
yield return new WaitForSecondsRealtime(0.3f);
FindObjectOfType<LevelLoader>().LoadNextLevel();
FindObjectOfType<SaveScene>().Load_Saved_Scene();
}
else
{
GameUI.ShowRestartButton();
}
}
public void RestartGame()
{
SceneManager.LoadScene(PlayerPrefs.GetInt("SavedScene"));
}
}
if anyone needs a script for object data, I can also provide it
Answer by BuzzyRoboYT · May 18 at 09:45 AM
What explosion animation do you mean? Is it one you have made yourself? There is no built-in explosion animation in unity, so either you have to get one online or from the asset store and import it into your project, then trigger the animation when the level ends.
Your answer
Follow this Question
Related Questions
How can I make the animation match when the NPC walks left or right? 0 Answers
Jump animation with a little bounce like towerfall 0 Answers
Why is this duplicate object not behaving like the original? 2 Answers
Is it possible to use JSON file to slice sprites? 0 Answers
simple explosion animation 1 Answer