interact-able objects

I have a script that im using to try and pick up something and then set it back down. here is my script.

if (PickedUp == 1) {
     if (Physics.Raycast (transform.position, -Vector3.up, hit)) {
        if (hit.distance <= 3) {
            RaycastHit.rigidbody.transform.position = pickupplace;
        }
     }
     else {
     }
}

So this script says if a raycast hits, and it hits within 3, then assign the hit rigidbody to a transform location called pickupplace. Any idea what im doing wrong?

1 Answer

1

http://forum.unity3d.com/threads/41530-Picking-up-and-holding-an-object

if you rather, i suppose im asking how to transform the position of the raycast hit rigidbody to the position of "pickupplace"

hit.transform.position = pickupplace;

ahh :D thank you. one more question, this script is attached onto my camera script and i am trying to have this raycast shoot out forwards, so Vector3.forward should work, but it isnt, any ideas?

You have a nasty habit of trying to get attributes out of the classes, instead of the relevant objects. Try transform.forward.

yea, i self taught myself all the JS i know so im kinda new to it :/