Answers for "Enemy chasing player script"

C#
0

Enemy chasing player script

[SerializeField] private float MoveSpeed = 4; 
 [SerializeField] private float MaxDist = 10; 
 [SerializeField] private float MinDist = 5;     

 function 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    
 }         
 } 
 }
Posted by: Guest on September-19-2021

Code answers related to "Enemy chasing player script"

C# Answers by Framework

Browse Popular Code Answers by Language