Arrow.cs 381 B

123456789101112131415161718192021
  1. using System.Collections;
  2. using UnityEngine;
  3. public class Arrow : MonoBehaviour
  4. {
  5. void Start()
  6. {
  7. StartCoroutine(DestroySelf());
  8. }
  9. void Update()
  10. {
  11. this.transform.position += transform.forward * Time.deltaTime * 10f;
  12. }
  13. IEnumerator DestroySelf()
  14. {
  15. yield return new WaitForSeconds(3f);
  16. Destroy(gameObject);
  17. }
  18. }