Skip to content

Instantly share code, notes, and snippets.

@deadasadodo
Created May 3, 2022 05:04
Show Gist options
  • Save deadasadodo/0b9036ad50573817de2506bbb45efadf to your computer and use it in GitHub Desktop.
Save deadasadodo/0b9036ad50573817de2506bbb45efadf to your computer and use it in GitHub Desktop.
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