Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Turret : Enemy
- {
- [SerializeField]
- private Transform riffleStart;
- [SerializeField]
- private GameObject bullet;
- private float coolDown = 1f;
- private float timer;
- void Start()
- {
- player = GameObject.FindObjectOfType<PlayerMove>().gameObject;
- health = 50;
- damage = 15;
- }
- protected override void Attack()
- {
- if (Vector3.Distance(transform.position, player.transform.position) < 20f)
- {
- transform.LookAt(player.transform.position);
- if (timer >= coolDown)
- {
- GameObject buf = Instantiate(bullet);
- buf.transform.position = riffleStart.transform.position;
- buf.transform.rotation = transform.rotation;
- buf.GetComponent<Bullet>().setDirection(transform.forward);
- timer = 0;
- }
- }
- timer += Time.deltaTime;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement