Advertisement
11eimilia11

WHY UNITY

Nov 11th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Vuforia;
  5.  
  6. public class NewBehaviourScript : MonoBehaviour
  7. {
  8.     // Start is called before the first frame update
  9.     void Start()
  10.     {
  11.        
  12.     }
  13.  
  14. Transform target;
  15.  
  16. void GetHouseTarget()
  17. {
  18.     GameObject go = GameObject.Find("ImageOat");
  19.    
  20.     if (go != null)
  21.     {
  22.         target = go.transform;
  23.     }
  24.     else
  25.      {
  26.         Debug.Log("House not found");
  27.     }
  28. }
  29.  
  30.     // Update is called once per frame
  31.     void Update()
  32.     {
  33.  
  34.         float distance = Vector3.Distance(transform.position, target.position);
  35.  
  36.         if (distance < 5)
  37.         {
  38.             print("THEY ARE CLOSE");
  39.         }
  40.  
  41.         else
  42.         {
  43.  
  44.             print("THEY ARENT CLOSE");
  45.         }
  46.  
  47.        
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement