Advertisement
kadyr

Untitled

Aug 21st, 2021
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Grenade : MonoBehaviour
  6. {
  7. //релазиация таймера
  8. private float time = 0;
  9. [SerializeField]
  10. private float coolDown = 3f;
  11.  
  12. private bool isPlayed;
  13. void Update()
  14. {
  15. time += Time.deltaTime;
  16. if (time > coolDown && !isPlayed)
  17. {
  18. //взрыв
  19. GetComponentInChildren<ParticleSystem>().Play();
  20. isPlayed = true;
  21. //уничтожение гранаты
  22. Destroy(this, 0.5f);
  23. }
  24. }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement