- Home /
Question by
pickle chips · Jun 25, 2013 at 02:02 AM ·
guidamageoverlap
make GUI not overlap?
In my game, when an enemy attacks the player a hitmarker appears on the player, and shows the damage, and it works fine
But If two enemies attack the player at the same time, the hitmarkers appear on top of eachother, so you can't see one of them. Is there a way to check if there's two hitmarkers on the screen at the same time or something so I can adjust the location appropriately? I just don't want the hitmarkers to overlap so you can see them both. Any suggestions?
Here's the code I'm using to draw the hitmarker
void OnGUI() {
Vector3 v3pos;
v3pos = target.transform.position;
v3pos = Camera.main.WorldToScreenPoint(v3pos);
v3pos.y += hitMarkY; //Offsetting the y coordinate
v3pos.y = Screen.height - v3pos.y;
v3pos.x -= hitMarkX; //Offsetting the x coordinate
if (showDamage > 0) {
GUI.Label(new Rect(v3pos.x, v3pos.y, 50, 50), damage.ToString(), hitMarker);
showDamage -= Time.deltaTime; // This is a timer for how long to display the hitmarker
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613104831im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
button drawn last not triggered 0 Answers
GUI Button overlap problem 1 Answer
How To Make Floating Combat Text In new UI System of 4.6 1 Answer
Choose which GUItext to display 1 Answer
2D GUI Group moving with players. 1 Answer