I have a scripts that attach to a enemy that once collision happens with our player the game restarts. I have a panel with an animation with in it, i would like this animation to be triggered once my player dies. Could somebody help me make a c-sharp death script the triggers the panel animation. Also if you could include a sound for when the player dies that would be much appreciate
Here’s my death script:
using UnityEngine;
public class death : MonoBehaviour
{
// The force which is added when the player jumps
// This can be changed in the Inspector window
public Vector2 jumpForce = new Vector2(0, 300);
// Update is called once per frame
void Update ()
{
// Jump
if (Input.GetKeyUp("space"))
{
GetComponent<Rigidbody2D>().velocity = Vector2.zero;
GetComponent<Rigidbody2D>().AddForce(jumpForce);
}
}
// Die by collision
void OnCollisionEnter2D(Collision2D other)
{
Die();
}
void Die()
{
Application.LoadLevel(Application.loadedLevel);
}
}