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;
}
Answer by jmonasterio · Dec 29, 2015 at 06:43 PM
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.
Your answer
Follow this Question
Related Questions
Storing any component inside a single variable. 1 Answer
How can I save the cloth component "edit constraint". 1 Answer
Rotating & fixing the position of an object to one spot 1 Answer
How to change childAlignment option/value on GridLayoutGroup component with script ? 1 Answer
ECS Entity not shown in the scene 1 Answer