Bow.cs 470 B

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