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

Calculate distance between player and object

$
0
0
Hello, I made a script to pick items up. I'm wondering if anyone can help me add some sort pf thing so that the script can detect how far away the player is. Basically so you can't pick the items up anywhere, and you have to be close to them. Thanks in advanced. #pragma strict var item : GameObject; function Start () { gameObject.transform.localRotation = Quaternion.Euler(0,0,0); } function Update () { if(Input.GetKey(KeyCode.E)) { Drop(); } } function Drop() { //Destroy the object that has this script attached Destroy(gameObject); }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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