Advertisement
kadyr

Untitled

Aug 29th, 2021
1,117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class Predator : Enemy
  4. {
  5.     private CharacterController cc;
  6.  
  7.     void Start()
  8.     {
  9.         cc = GetComponent<CharacterController>();
  10.     }
  11.     public override void Move()
  12.     {
  13.         if (Vector3.Distance(transform.position, player.transform.position) < 100f)
  14.         {
  15.             transform.LookAt(player.transform);
  16.             cc.Move(transform.forward * Time.deltaTime * 2);
  17.         }
  18.     }
  19.  
  20.     public override void Attack()
  21.     {
  22.         if (Vector3.Distance(transform.position, player.transform.position) < 3f)
  23.         {
  24.             player.GetComponent<PlayerController>().ChangeHealth(-100);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement