Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Turret : Enemy
- {
- [SerializeField]
- GameObject bullet;
- [SerializeField]
- GameObject rifleStart;
- [SerializeField]
- float cooldown = 1f;
- float timer = 0;
- float area = 25;
- void Start() { }
- public override void Move()
- {
- //I CAN'T MOVE IF YOU DON'T UNDERSTAND!!!!
- }
- public override void Attack()
- {
- if (Vector3.Distance(transform.position, player.transform.position) < area)
- {
- transform.LookAt(player.transform);
- timer += Time.deltaTime;
- if (timer > cooldown)
- {
- timer = 0;
- GameObject buf = Instantiate(bullet);
- buf.transform.position = rifleStart.transform.position;
- buf.transform.rotation = transform.rotation;
- buf.GetComponent<Bullet>().setDirection(transform.forward);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement