Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Carrying physical game objects in javascript scripting problems with Unity 5.

$
0
0
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.

Viewing all articles
Browse latest Browse all 1875

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>