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
Answer by Rodogs · Jul 27, 2016 at 02:26 PM
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; https://www.youtube.com/watch?v=ceIZqcp7N6A&list=PLZ1b66Z1KFKik2g8D4wrmYj4yein4rCk8∈dex=6
yeah that's kinda what i needed but more... rts looking with the green object before you place it and for it to snap to the terrain/object also it would be nice to be able to rotate it thanks for your help though
Your answer
Follow this Question
Related Questions
How can I temporary increase the size of an object? 2 Answers
Timer wont work 0 Answers
Make enemy patrol without Nav Points? 0 Answers
random spawn enemy problem 0 Answers