EnemyRangeAttack.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. using UnityEngine;
  5. public class EnemyRangeAttack : MonoBehaviour
  6. {
  7. [HideInInspector]
  8. public GameObject Prefab;
  9. [HideInInspector]
  10. public Transform spawn;
  11. [Header("Время между выстрелами")]
  12. public float attackTime;
  13. [Header("Галочка, если танк смотрит вправо")]
  14. public bool isRight=false;
  15. IEnumerator Shoot()
  16. {
  17. Instantiate(Prefab, spawn.position, Quaternion.identity, this.transform);
  18. yield return new WaitForSeconds(attackTime);
  19. StartCoroutine(Shoot());
  20. }
  21. IEnumerator sturt()
  22. {
  23. yield return new WaitForSeconds(0.7f);
  24. StartCoroutine(Shoot());
  25. }
  26. void Start()
  27. {
  28. StartCoroutine(sturt());
  29. if (isRight == true)
  30. {
  31. Vector3 scaler = transform.localScale;
  32. scaler.x *= -1;
  33. transform.localScale = scaler;
  34. }
  35. }
  36. // Update is called once per frame
  37. void Update()
  38. {
  39. }
  40. }