using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; public class player_move : MonoBehaviour { public GameObject bullet; public Transform firepoint; public Transform bulletFolder; void Update() { //判別滑鼠觸控 if (Input.GetMouseButtonDown(0)) { //1.ray Ray r1 = Camera.main.ScreenPointToRay(Input.mousePosition); //2.hit RaycastHit h1; //3.if hit or not if(Physics.Raycast(r1,out h1)==true) { this.gameObject.GetComponent().SetDestination(h1.point); } } //判別按了F,開火 if(Input.GetKeyDown(KeyCode.F)) { GameObject node = Instantiate(bullet, bulletFolder); node.transform.position = firepoint.position; } } }