Hey everyone,
I am trying to add a health bar to a moving unit in an RTS. When I apply my code I used for a tower object the health bar ends up in weird places. I just want to position it above the unit. It needs to be able to move with the unit, and stay with the unit if the camera moves. I tried this so far,
private void OnGUI(){
//health bar for player units
GUI.DrawTexture(new Rect (HealthBarPos.x,(Screen.height-HealthBarPos.y),length*(unitHealthBarLength/unitHealthBarMaxLength),5),selectionHighLight);
}
This code is attached to the unit, so I didnt need to reference it as an object…i think. Each time I run the code and have the first two parameters change the health bar always ends up in wierd places. Anyone have any ideas? Thanks,