Problem with gravity with regidbody.

Hey guys, i have a very big problem in my Unity. I saw some videos that show me how to grab an object. An how to put it down again. So my problem is that after I learned to “hold” an object, and release it. It is still on mid air. I tried to use regidbody, but no matter what i do. I can’t figure it out. Hope you will help me from Jaani.

Here is my script:

var onhand : Transform;

function Update () {

}

function OnMouseDown () {
GetComponent.().useGravity = false;
this.transform.position = onhand.position;
this.transform.parent = GameObject.Find("FPSController").transform;
this.transform.parent = GameObject.Find("FirstPersonCharacter").transform;
}

function OnMouseUp () { 
this.transform.parent = null; 
GetComponent.().UseGravity = true;
}

You typed useGravity wrong on line 16. Should not be capitalized.

You will run into these kinds of problems with JavaScript until you learn about the the strict pragma. Add this at the top of your script.

#pragma strict

My opinion: You are so much better off using C#, if you can.

Okay, will do. And thanks for the help!