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

Pick-Up Object With Mouse Hold

$
0
0
I am trying to make my game so that you can look at an object, and if close enough, pick it up by holding mouse down. I have created an empty object and placed it where I want the held object to be. I watched a tutorial that used one script. Here is the code I am Using. It is in JavaScript: var target : Transform; function Update () { } function OnMouseDown() { this.transform.position = target.position; this.transform.parent = GameObject.Find("FPSController (1)").transform; // this.transform.parent = GameObject.Find("FirstPersonCharacter").transform; } function OnMouseUp() { this.transform.parent = GameObject.Find("FPSController (1)").transform; this.transform.parent = null; } When I apply the script nothing happens. I walk over to the object and press the mouse button, but it does not respond to my mouse clicking. It is worth noting that my pickUpTarget empty object is a child of FPSController but not of FirstPersonCharacter. I did this because I do not wan't the object moving up and down with the camera, just left and right. Thanks

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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