Hello, I made a script to pick items up. I'm wondering if anyone can help me add some sort pf thing so that the script can detect how far away the player is. Basically so you can't pick the items up anywhere, and you have to be close to them.
Thanks in advanced.
#pragma strict
var item : GameObject;
function Start ()
{
gameObject.transform.localRotation = Quaternion.Euler(0,0,0);
}
function Update ()
{
if(Input.GetKey(KeyCode.E))
{
Drop();
}
}
function Drop()
{
//Destroy the object that has this script attached
Destroy(gameObject);
}
↧