Here is what I have so far!
How do I make the HealthBars hide when the camera is facing away?
Can you see in the video how they are floating all over the place looking horrible?
Here is what I have so far!
How do I make the HealthBars hide when the camera is facing away?
Can you see in the video how they are floating all over the place looking horrible?
Fixed GUI issue with this
void OnGUI()
{
InitStyles();
// Draw a Health Bar
// Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
if (Vector3.Angle(Camera.main.transform.forward, transform.position - Camera.main.transform.position) < 60)
{
// draw health bar background
GUI.color = Color.grey;
GUI.backgroundColor = Color.grey;
GUI.Box(new Rect(pos.x - 26, Screen.height - pos.y + 20, Combat.maxHealth / 2, 7), ".", backStyle);
// draw health bar amount
GUI.color = Color.green;
GUI.backgroundColor = Color.green;
GUI.Box(new Rect(pos.x - 25, Screen.height - pos.y + 21, combat.health / 2, 5), ".", healthStyle);
}
}