Currently, I'm making a small game in unityscript, and I have a character with the standard first person controller script. Problem is, when I use the following .js script, a object that is being carried goes out of control. Floating around, to spinning in a type of motion like it's in a invisible tornado. And for the record this is in unity 5.3.3.
Here is the small 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;
}
I did try using GetButtonDown as well, with no success. Bare in mind, the GameObject that is suppose to be carried does have a rigidbody. And the player does have one as well.
How can this problem be solved?
Thanks.
↧