CreateProjectile.cs 842 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using UnityEngine;
  2. namespace ZakhanSpellsPack
  3. {
  4. public class CreateProjectile : MonoBehaviour
  5. {
  6. public Rigidbody Fireball;
  7. public float Time = 1.0f;
  8. private bool CreateInstances = true;
  9. private Rigidbody Instance;
  10. void Start()
  11. {
  12. InvokeRepeating("Create", Time, Time);
  13. }
  14. void Update()
  15. {
  16. if (Instance == null)
  17. {
  18. CreateInstances = true;
  19. }
  20. }
  21. void Create()
  22. {
  23. if (CreateInstances)
  24. {
  25. Instance = Instantiate(Fireball, transform.position, transform.rotation);
  26. CreateInstances = false;
  27. Instance.transform.SetParent(this.transform);
  28. }
  29. }
  30. }
  31. }