How To Duplicate Canvas To Follow Player
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;
Your answer
Follow this Question
Related Questions
Operator '==' is ambiguous on operands of type 'Vector2' and 'Vector3' 1 Answer
Having trouble with Vectors 1 Answer
Vectors side determing by a line. Please help me out !!!! 0 Answers
Moved GameObject under Canvas (Parent), transform.position vector coordinates mismatch 0 Answers
Move a object along a vector 1 Answer