Quantcast
Channel: Unity3D Student » space
Viewing all articles
Browse latest Browse all 2

Beginner B21 – Finding Distance with Vector3

0
0

Finding the distance between two points in 3D space using Vector3.Distance command

Code Used (Javascript)

  1. var box : Transform;
  2.  
  3. function Update () {
  4.  
  5.  var dist : float = Vector3.Distance(box.position, transform.position);
  6.  Debug.Log(dist);
  7.  
  8.  if(dist <= 10){
  9.   light.enabled = true;
  10.  }else{
  11.   light.enabled = false;
  12.  }
  13. }

Further Reading


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images