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

How To Duplicate Canvas To Follow Player

$
0
0
Recently, I've been trying to get character health and nametag to follow the enemies. This was a success. However, I am having trouble with getting the canvas that holds the health and nametag to be duplicated whenever the enemy has died (another enemy spawns itself when the an enemy dies), and for the duplicated health and nametag in the duplicated canvas to follow the newly spawned enemy. My code for respawning enemy: for (int i = 0; i < spawnNum; i++) { Vector3 SkeletonPos = new Vector3 (this.transform.position.x + Random.Range (-15.0f, 15.0f), this.transform.position.y + Random.Range (0.0f, 0.0f), this.transform.position.z + Random.Range (-15.0f, 15.0f)); Instantiate (Skeleton, SkeletonPos, Quaternion.identity); } My code for health and nametag following enemy: Vector3 enemyHealthPos = Camera.main.WorldToScreenPoint (this.transform.position); Vector3 EnemyNamePos = Camera.main.WorldToScreenPoint (this.transform.position); EnemyNameTag.transform.position = EnemyNamePos; EnemyHealth.transform.position = enemyHealthPos;

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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