SmokeDestroy.cs 847 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SmokeDestroy : MonoBehaviour
  5. {
  6. public float stayTime;
  7. [HideInInspector]
  8. public float time;
  9. public float hitRate;
  10. private void Update()
  11. {
  12. time += Time.deltaTime;
  13. if(time >= stayTime)
  14. {
  15. gameObject.SetActive(false);
  16. }
  17. }
  18. private void OnTriggerEnter(Collider other)
  19. {
  20. AttackTrigger attackTrigger = other.GetComponent<AttackTrigger>();
  21. if (attackTrigger != null)
  22. {
  23. attackTrigger.hitRate = hitRate;
  24. }
  25. }
  26. private void OnTriggerExit(Collider other)
  27. {
  28. AttackTrigger attackTrigger = other.GetComponent<AttackTrigger>();
  29. if (attackTrigger != null)
  30. {
  31. attackTrigger.hitRate = 1;
  32. }
  33. }
  34. }