Quantcast
Channel: Latest Questions by Fox-Handler
Viewing all articles
Browse latest Browse all 90

Mathf.Infinity

$
0
0
Can someone explain how Mathf.infinity is working in this script? The script is supposed to turn an instantiated bullet towards the closest target, but I can't really tell what Math.infinity is actually doing. // Update is called once per frame void Update () { float nearestDistance = Mathf.Infinity; GameObject nearestEnemy = null; foreach(GameObject obj in GameObject.FindGameObjectsWithTag("Enemy")) { //float distance = Vector3.Distance(transform.position - obj.transform.position); float distance = (transform.position - obj.transform.position).sqrMagnitude; if(distance

Viewing all articles
Browse latest Browse all 90

Latest Images

Trending Articles





Latest Images