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

Check distance between all objects on a list?

$
0
0
I'm trying to make it so an object checks how far it is from any object from a list. I have this script so far but it seems to only work with the closest one and ignores all others public var objects : GameObject[]; function Start () { objects = GameObject.FindGameObjectsWithTag("Tree"); } function Update () { for (var object in objects) { if ((transform.position - object.transform.position).magnitude < 10) { //Do something } else { //Do something else } } }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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