Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

How do I make it so a death animation will play when I hit an enemy?

$
0
0
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

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>