Okay, i’m trying to create gui system for objects in my scene that follow them around (health shield name background for bars and so on), right now my biggest worries are that hierarchy is getting flooded by guitext and guitexture object clones as i need to instantiate each one for every object so here is my question:
that piece of code gives you XYZ values from wich you can see if the target is in front of you or not, and destroy the bars or set size to 0 or something like that…
this is how im using it is somewhere along like this:
bool visible = false;
abCookie = Camera.main.WorldToViewportPoint(transform.position);
//abCookie.x checks if it is in view vertically
//abCookie .y checks if it is in view horizontally
//abCookie .z checks if we are front or behind the target
//abCookie .z < maxDist just checks if its otherwise in view but if its too far it doesn't create bars
if (abCookie.x > 0 && abCookie.x < 1 && abCookie.y > 0 && abCookie.y < 1 && abCookie.z > 0 && abCookie.z < maxDist)
{
if (!visible)
{
CreateBars();
}
visible = true;
}
else
{
if (visible)
{
RemoveBars();
}
visible = false;
}