纳金网

标题: 判断鼠标是否点击到目标物并播放攻击动作和特效 [打印本页]

作者: 王者再临    时间: 2014-8-29 02:19
标题: 判断鼠标是否点击到目标物并播放攻击动作和特效
  1. void Update () {

  2.         Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
  3.         RaycastHit hit;
  4.         if (Physics.Raycast (ray, out hit))
  5.         {
  6.             if(Input.GetMouseButtonDown(0))
  7.             {
  8.                 GameObject hitobj = hit.collider.gameObject;
  9.                 if (hitobj.transform.name.CompareTo("Plane") == 0)
  10.                 {
  11.                     print (Input.mousePosition);
  12.                     Instantiate (Resources.Load ("effects/DEFX/PhysicalEffects/ComboRipEffect"), fighter.transform.position, fighter.transform.rotation);
  13.                     animation.Play ("attack");
  14.                 }
  15.             }
  16.         }
复制代码

作者: hyui    时间: 2014-8-29 03:09
Thanks for sharing !
作者: cgjch8    时间: 2014-8-29 09:15
Thanks for sharing
作者: 嵐淵瑟    时间: 2014-10-16 16:15
支持一個,感謝分享~~




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5