Bow.cs 514 B

123456789101112131415161718192021222324252627
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. public class Bow : MonoBehaviour
  4. {
  5. public static Bow Instance;
  6. public Text info;
  7. void Start()
  8. {
  9. Instance = this;
  10. }
  11. void Update()
  12. {
  13. #if UNITY_EDITOR
  14. if (Input.GetKeyDown(KeyCode.S)) Shoot();
  15. #endif
  16. }
  17. public void Shoot()
  18. {
  19. Transform bowTF = transform;
  20. Transform arrowTF = transform.Find("Arrow");
  21. Instantiate(arrowTF.gameObject, arrowTF.position, bowTF.rotation).SetActive(true);
  22. }
  23. }