looting an item

how about a looting script or parenting an object to the player… ex. you have an object in front of you then when you step on it, something will appear on the screen then when you press F you can have the object…

the “something will appear on the screen” is just an option i can do that. the main question is how can you have that object?


var loot : GameObject;
var near : boolean = false
function OnCollisionEnter (loot : player) {
Debug.Log("You are stepping on an object, press F to pick it up");

near = true;


function OnCollisionExit (loot : player) {

near = false;


function Update {

if (Input.GetKeyDown ("F") && near == true) {
//Do stuff