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

Enemy Tag in Range

$
0
0
Just trying to get this script to work... Checks if animation is playing then any enimes near with the tag "enemy" gets HP taken away if (animation["attack"].enabled == true) { GameObject[] enemies = GameObject.FindGameObjectsWithTag("enemy"); foreach(GameObject target in enemies) { float distance = Vector3.Distance(target.transform.position, transform.position); if(distance < 4) { //Rigidbody clone; //clone = Instantiate(projectile, target.transform.position, target.transform.rotation) as Rigidbody; AttackandHP eh = (AttackandHP)target.GetComponent ("AttackandHP"); eh.AdjustCurrentHealth (-damage); SpawnPts(); //eh.audio.PlayOneShot(eh.Hit, 1.0f); } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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