I’ve trying to get this to work for a while… When i look at an object i want the words Press E to pickup to be displayed…only when im near the object and looking at it? Help please
What you could do is either a OnMouseOver(){} void or function and the script must be added to the pickup object. Or you could use vector3.distance to make it that you pick it up when your near(Note: this will not use direction so you can pick it up without looking at it). I would go to the unity3d script reference and look up these two things, but they will not be great but its pretty hard to make it work perfectly.
var Highlighted : boolean;
var ChosenColour : Color;
var PickUp : String = “This Cool Thing Im Looking At”;
function OnMouseOver(){
transform.renderer.material.color = ChosenColour;
Highlighted = true;
}
function OnMouseExit(){
transform.renderer.material.color = Color.white;
Highlighted = false;
}
function OnGUI(){
if(Highlighted == true){
GUI.Label(Rect(Screen.width/2,Screen.height/2,200,20),"Press E to Pick up "+PickUp);
}
}