how to place and pickup and object in first person

hello, i’m trying to create a system where you can place an object on the terrain or on another object in front of the camera and show a green image of that object like in rust, but i then need to be able to pick that object up again if it needs to be replaced., I’m currently using the realistic fps prefab if that’s useful to know.

i’ve been searching for a tutorial or something because my coding knowledge is very limited and would rely appropriate it if someone could point me to a YouTube vid or something to help me out.

thanks for your time

This JS script should assist you, it’s fairly explanatory what to do to get it functioning.

var target  :  Transform;

function Update() {
}

function OnMouseDown() {
this.transform.position = target.position;
this.transform.parent = GameObject.Find("FPSController").transform;
this.transform.parent = GameObject.Find("FirstPersonCharacter").transform;
}

function OnMouseUp() {
this.transform.parent = GameObject.Find("FPSController").transform;
this.transform.parent = null;
}

If you’re unable to go from there, here is a video tutorial using the same script; Unity Tutorial For Beginners - How To Make A Game - Part 006 - Pick Up Objects - YouTube