Search Unity

Triggering Explosions When The Player Is At A Certain Point

Discussion in 'Animation' started by Nikola310, Dec 17, 2015.

  1. Nikola310

    Nikola310

    Joined:
    Oct 24, 2015
    Posts:
    35
    Hello.
    I've been looking for over an hour, and I can't find the solution to my problem.
    I'm making an advanced Roll A Ball game, and I want to add explosions when the Player falls off a platform.
    Where do I insert the Explosion animation? How can I get it? I've tried downloading assets, but there are prefabs in them, and I don't know how to use them.
    Here is my "DeathFall" Script (Restarts the scene when you fall off a platform):

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.SceneManagement;
    4.  
    5. public class DeathFall : MonoBehaviour {
    6.  
    7.  
    8.     void Update()
    9.     {
    10.         if(gameObject.transform.position.y <= -20)
    11.         {
    12.             //I Want the explosion animation to play when the player is at -20 Y
    13.         }
    14.  
    15.         else if(gameObject.transform.position.y <= -35)
    16.         {
    17.             SceneManager.LoadScene(Application.loadedLevel);
    18.             //This restarts the scene- shortly after the explosion
    19.         }
    20.     }
    21. }