public static bool isShow = false;//特效
public int enemyHp = 3;//敌人血量
public int playerHp = 10;//玩家血量
public static GameManager gm;//unity单例写法
void Start () {
gm = this;
}
if (Input.GetMouseButtonDown(0))
{
//Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
//Ray ray = new Ray(playerPos.position, zhiZhu.position);//射线:玩家到蜘蛛的位置,源头只有蜘蛛
RaycastHit hit;
//if (Physics.Raycast(ray, out hit,100))
Vector3 dir = transform.TransformDirection(transform.forward);//TransformDirection向前方向
if (Physics.Raycast(playerPos.position,dir,out hit,100))
//playerPos.position:枪口 dir:向前 out hit:射线 100:长度
{
Debug.DrawLine(playerPos.position, hit.point, Color.red);//绘制一条红色的射线
//射击动画
//an.Play("Shoot");
//an.CrossFade("Shoot", 0.167f);
ps = PlayerState.Shoot;
GetState(ps);
//播放射击音效
audios.Play();