Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.AI;
  5.  
  6. public class IA : MonoBehaviour
  7. {
  8.     GameObject[] agents;
  9.     // Start is called before the first frame update
  10.     void Start()
  11.     {
  12.         agents = GameObject.FindGameObjectsWithTag("IA");
  13.     }
  14.  
  15.     void Update() {
  16.         if (Input.GetMouseButtonDown(0)) {
  17.             RaycastHit hit;
  18.             if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100)) {
  19.                 foreach(GameObject a in agents) {
  20.                     a.GetComponent<IA>().nma.SetDestination(hit.point);
  21.                 }
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement