UNity3D—游戏项目之打怪.docVIP

  • 6
  • 0
  • 约2.44千字
  • 约 8页
  • 2018-11-23 发布于江苏
  • 举报
Unity3D——游戏项目之打怪 ?今天老师教了我们在游戏中如何去打怪: ?? ? ? ? 首先给主人公添加一个脚本 让他可以跑步 打怪: ? ? ? ?public class BoyPlayer : MonoBehaviour { ? ? private ?NavMeshAgent agent; ? ? public GameObject hero; ? ? public static int i = 0; ? ? private bool flag = false; ? ? public bool attackFlag = false; ? ? private ?float ?timer=2f; void Start ()? { ? ? ? ? agent = GetComponentNavMeshAgent(); } ? ? void Update() ? ?? { ? ? ? ? if (Input.GetMouseButtonDown(0)) ? ? ? ?? { ? ? ? ? ? ? Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); ? ? ? ? ? ?? RaycastHit hitinfo; ? ? ? ? ? ? if (Physics.Raycast(ray, out hitinfo

文档评论(0)

1亿VIP精品文档

相关文档