Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class GPS : MonoBehaviour {
  6.  
  7.     public GameObject Arrow;
  8.     public GameObject[] ParkingSpace;
  9.  
  10.     public static GameObject ParkingDestination;
  11.  
  12.     private GameObject Player;
  13.  
  14.     void Start() {
  15.         Player = GameObject.FindWithTag("Lambo");
  16.     }
  17.  
  18.     public static void SearchForSpot() {
  19.  
  20.         var ParkingSpots = GameObject.FindGameObjectsWithTag("Parking_Linija");
  21.  
  22.         for (int i = 0; i < ParkingSpots.Length; i++) {
  23.  
  24.             var ParkContol = ParkingSpots[i].GetComponent<ParkingController>();
  25.  
  26.             if(!ParkContol.JeLiZauzeto) {
  27.  
  28.                 ParkingDestination = ParkingSpots[i];
  29.                 break;
  30.             }
  31.         }
  32.     }
  33.  
  34.     void Update() {
  35.  
  36.         Arrow.transform.position = Player.transform.position;
  37.         PointArrow(ParkingDestination.transform);
  38.     }
  39.  
  40.     private void PointArrow(Transform target) {
  41.  
  42.         Vector3 lookPos = target.position - Arrow.transform.position;
  43.  
  44.         Quaternion rotation = Quaternion.LookRotation(lookPos);
  45.  
  46.         Arrow.transform.rotation = rotation;
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement