Esempio n. 1
0
    public void HitSomething(RaycastHit hit)
    {
        if (m_delayedTime == shootDelay)
        {
            ///////////////////////////////
            // 애니메이션 및 사운드
            ///////////////////////////////

            // 사격 애니메이션
            animator.SetTrigger("Fire");
            if (muzzleFlash != null)
            {
                muzzleFlash.Emit();
            }

            // 바라보는 방향
            Vector3 focus     = (hit.point - transform.position).normalized;
            Vector3 forward   = transform.forward;
            Vector3 forward2d = new Vector3(forward.x, 0, forward.z);
            Vector3 focus2d   = new Vector3(focus.x, 0, focus.z);
            forward2d.Normalize();
            focus2d.Normalize();
            Vector3 cross = Vector3.Cross(forward2d, focus2d);
            float   angle = cross.sqrMagnitude;
            if (cross.y < 0)
            {
                angle *= -1;
            }
            m_focusAngle = angle;

            // 발사
            Shoot(hit);

            // 카운트 초기화
            m_delayedTime = 0;
        }
    }