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

How do I make it so my enemy is hit 8 times and is destroyed?

$
0
0
i know there are other posts about this... but i have scoured the internet and have found nothing that solves my problem. i have a bullet prefab that my character shoots with a altered script i used for picking up items and destroying them. basically when the bullet prefab hits the character he is destroyed after one hit. i need it so he can take multiple hits and then destroy. it seems simple enough...but i just cant get it. i have tried for a week now and my brain is melting. here is the script: #pragma strict private var score : int = 0; var counter = 0; var guiScore : GUIText; var enemygrunt : AudioClip; function Start () { guiScore.text = "KILLS: 0"; } function OnCollisionEnter(col : Collision){ if(col.collider.name == "ClodHopplerPrefab"){ AudioSource.PlayClipAtPoint(enemygrunt, transform.position); counter +=1; if (counter ==2); Destroy(gameObject); score += 1; guiScore.text = "KILLS: " + score; print("collide with enemy"); } } any help would be great. i just cant seem to figure out what to do. i know this is a script for my "bullet" prefab...but do i need to add anything to my enemy to have it work? thanks again. -i'm dying over here.

Viewing all articles
Browse latest Browse all 1488

Trending Articles