FullscreenClearBubbleBehavior.cs 718 B

12345678910111213141516171819202122232425262728293031
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class FullscreenClearBubbleBehavior : MonoBehaviour
  5. {
  6. const float SpreadSpeed = 120f;
  7. const float Lifetime = 2f;
  8. float Age = 0f;
  9. private SphereCollider ClearCollider;
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. ClearCollider = gameObject.GetComponent<SphereCollider>();
  14. }
  15. // Update is called once per frame
  16. void Update()
  17. {
  18. Age += Time.deltaTime;
  19. if (Age > Lifetime)
  20. {
  21. Destroy(gameObject);
  22. return;
  23. }
  24. float radius = SpreadSpeed * Time.deltaTime;
  25. ClearCollider.radius += radius;
  26. }
  27. }