**GUI to world position for GUI Button not working on landscape (Only works on portrait)**
**
I'm making the healthbar for enemies.
The healthbar works and follows enemies very fine in portrait mode of Android phone. But when i convert it to landscape mode, the positions of healthbars aren't exactly on top of the enemies.
**
The healthbars still follow enemies, but their positions are e.g, 1-2 inches away from the enemies (Only happens in landscape mode).
For more info, i'm initiating the healthbar (GUI panel and a gui text inside it (not GUITexture)). And while i initiate it, i'm making it the child of my canvas.
**
Here's my code,
**
void Update () {
Vector2 targetPos = Camera.main.WorldToScreenPoint (Enemy.transform.position);
EnemyHealthBar.transform.position = targetPos;
}
↧