var distance : float;
var weaponUpgrader : GameObject;
var player : GameObject;
function OnGUI()
{
distance = Vector3.Distance(weaponUpgrader.transform.position, player.transform.position);
}
if(distance < 2.6)
if(Input.GetKeyDown(KeyCode.F))
//Cant figure out how the GUI enabling works here...
if (distance > 2.6)
{
print("Cant reach the object, text disabled");
(guiText.GetComponent(GUIText) as GUIText).enabled = false;
guiText.text = "This Text Is Now Disabled";
}
}
This is my script for players weapon box:
I need help with GUI enabling when you are near the object (if(distance < 2.6))
and when F is pressed, the GUI.Label,Box, or Button will open up, and when he presses F again, the GUI will disapper and “Weapon Upgrader
press F” will be enabled again.
Thanks for the help in advance!