void Update() { if (m_bDead == true) { return; } if (Input.GetMouseButtonDown(0)) { if (m_PlayerShotGun.m_Animation.isPlaying == false) { // Create a vector at the center of our camera's viewport Vector3 rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.0f)); // Declare a raycast hit to store information about what our raycast has hit RaycastHit hit; // Check if our raycast has hit anything if (Physics.Raycast(rayOrigin, fpsCam.transform.forward, out hit, weaponRange)) { if (hit.transform.tag == "Zombie") { EnemyMgr zomb = hit.collider.GetComponent <EnemyMgr>(); if (zomb.Equals(this)) { zomb.m_fHP -= 50; TAudioMgr.Instance.PlayEffect("zo_hit"); Debug.Log(zomb.m_fHP.ToString()); GameObject obj = TPrefabMgr.Instance("Blood", "Blood", hit.point.x, hit.point.y, hit.point.z); } } if (m_fHP <= 0.0f && m_bDead == false) { //fpc.m_iScore += 10; //Debug.Log(fpc.m_iScore.ToString()); m_bDead = true; TAudioMgr.Instance.PlayEffect("zo_pain"); m_Animation.CrossFade(m_DieAnimation.name); Invoke("DestroyNow", 10.0f); } //int a = 1; //// Set the end position for our laser line //laserLine.SetPosition(1, hit.point); //// Get a reference to a health script attached to the collider we hit //ShootableBox health = hit.collider.GetComponent<ShootableBox>(); //// If there was a health script attached //if (health != null) //{ // // Call the damage function of that script, passing in our gunDamage variable // health.Damage(gunDamage); //} //// Check if the object we hit has a rigidbody attached //if (hit.rigidbody != null) //{ // // Add force to the rigidbody we hit, in the direction from which it was hit // hit.rigidbody.AddForce(-hit.normal * hitForce); //} } } } if ((m_Player != null) && (m_fHP > 0)) { //if (StaticVars.b_isGameOver == false) //{ Vector3 vPos = m_Player.position; vPos.y += 1.0f; Vector3 vRocketDirection = (vPos - transform.position).normalized; // 조준을 시작한 상태가 아니라면 추적, if (Shoot(vRocketDirection)) { Run(); } else { // 웨이포인트로부터 특정 거리 이상 떨어져 있는지 확인 // m_fWaypointDistance 이상 떨어져 있으면 추적이나 공격을 멈추고 // 웨이포인트로 돌아간다. if (m_WayPoint.AwayFromWaypoint(transform, m_fWaypointDistance)) { m_bAiming = false; m_bRun = false; } } if (!m_bAiming) { NormalMove(vRocketDirection); } else { AttackMove(vRocketDirection); } //} //else //{ // m_Animation.CrossFade(m_IdleAnimation.name); //} } }