Hi guys, I am working on a 2d infinite runner game, and I don't know how to play a death animation when I hit an enemy. I added a 2D box collider and a 2D rigidbody, but I don't know how to make it so that when the player is running and hits an enemy, a death animation plays?
Here is my script:
using System;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace UnityStandardAssets._2D
{
public class Restarter : MonoBehaviour
{
void OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.tag == "Enemy")
GetComponent().Play("RedGianDEATHTOALL");
{
if (coll.gameObject.tag == "Enemy")
coll.gameObject.SendMessage("ApplyDamage", 10);
}
}
}
}
Any ideas?
A.K.A, Ignore the title of my script. I just edited a script that came with Unity3D
↧