- Home /
GUILabel to GUIText or Textmesh
Hi everyone, I'm having a little problem with my script:
#pragma strict
var targetScreenPosition : Vector3;
var Mname = "MonsterName";
function Start () {
}
function Update () {
}
function OnGUI(){
targetScreenPosition = Camera.main.WorldToScreenPoint(transform.position);
targetScreenPosition.y = Screen.height - targetScreenPosition.y;
targetScreenPosition.x = targetScreenPosition.x - 20;
if(targetScreenPosition.z > 0){
GUI.Label (new Rect (targetScreenPosition.x,targetScreenPosition.y,100,50),Mname);
}
}
What I'm trying to do here is an script that shows name of monster to the player always right (it turns where player goes) but the problem with this is I can't hide GUILabel's if they're behind the wall. So I would need to transform this script so it works with GUIText or Textmesh so I could hide that text if player doesnt see that current gameobject, but I dont really have no idea how to get it work with textmeshes or guitext so that those would load Mname variable as their texts.
I'm sorry if this has been an bad explanation.
Hi
$$anonymous$$aybe you can check with a raycast if there is not any object between the player and the monster before displaying the name.
Your answer
Follow this Question
Related Questions
How can I display ligatures? (in TextMesh and/or GUIText) 0 Answers
3D Text (TextMesh) not updated/redrawn every frame (android only) 0 Answers
I want to change TextMeshProUGUI based on value of a float, but I cant seem to work it. 0 Answers
Enable ChildObject of Player with OnTriggerEnter? Or a whole different method? 0 Answers
GUI Label Text Sizing problem 1 Answer