Advertisement
kadyr

Untitled

Aug 29th, 2021
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Turret : Enemy
  6. {
  7. [SerializeField]
  8. GameObject bullet;
  9.  
  10. [SerializeField]
  11. GameObject rifleStart;
  12.  
  13. [SerializeField]
  14. float cooldown = 1f;
  15.  
  16. float timer = 0;
  17. float area = 25;
  18.  
  19. void Start() { }
  20.  
  21. public override void Move()
  22. {
  23. //I CAN'T MOVE IF YOU DON'T UNDERSTAND!!!!
  24. }
  25.  
  26. public override void Attack()
  27. {
  28. if (Vector3.Distance(transform.position, player.transform.position) < area)
  29. {
  30. transform.LookAt(player.transform);
  31.  
  32. timer += Time.deltaTime;
  33. if (timer > cooldown)
  34. {
  35. timer = 0;
  36. GameObject buf = Instantiate(bullet);
  37. buf.transform.position = rifleStart.transform.position;
  38. buf.transform.rotation = transform.rotation;
  39. buf.GetComponent<Bullet>().setDirection(transform.forward);
  40. }
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement