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

How to use collision.name in custom function

$
0
0
So at the moment I'm suck trying to make a enemy stop after being hit. The problem is that I can't use the collision.name because it doesn't exist in the context but I also can't put Collider2D as a parameter on the end of the function because I need the int damage there. So how would I be able to do this? public void TakeDamage(int damage) { anim.SetTrigger("hurt"); if(collision.name == Hawk) { GetComponent().enabled = true; } health -= damage; if (health <= 0) { Destroy(gameObject); } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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