Advertisement
Polarwinds

Basic Ai

Oct 21st, 2014
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. var Player : Transform;
  2.  var MoveSpeed = 4;
  3.  var MaxDist = 10;
  4.  var MinDist = 5;
  5.  
  6.  
  7.  
  8.  
  9.  function Start ()
  10.  {
  11.  
  12.  }
  13.  
  14.  function Update ()
  15.  {
  16.      transform.LookAt(Player);
  17.      
  18.      if(Vector3.Distance(transform.position,Player.position) >= MinDist){
  19.      
  20.           transform.position += transform.forward*MoveSpeed*Time.deltaTime;
  21.  
  22.            
  23.            
  24.           if(Vector3.Distance(transform.position,Player.position) <= MaxDist)
  25.               {
  26.                  //Here Call any function U want Like Shoot at here or something
  27.     }
  28.    
  29.     }
  30.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement