Created
May 3, 2022 05:04
-
-
Save deadasadodo/0b9036ad50573817de2506bbb45efadf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class AIController : MonoBehaviour | |
{ | |
public Transform Player; | |
int MoveSpeed = 4; | |
int MaxDist = 10; | |
int MinDist = 5; | |
void Start() | |
{ | |
} | |
void Update() | |
{ | |
transform.LookAt(Player); | |
if (Vector3.Distance(transform.position, Player.position) >= MinDist) | |
{ | |
transform.position += transform.forward * MoveSpeed * Time.deltaTime; | |
if (Vector3.Distance(transform.position, Player.position) <= MaxDist) | |
{ | |
//Here Call any function U want Like Shoot at here or something | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment