Beispiel #1
0
    public void NormalBullet(Collision collision)
    {
        Vector3 incomingVec = transform.position - BeforePos;          // 입사각 => 충돌지점 - 출발지점
        Vector3 normalVec   = collision.contacts[0].normal;            // 법선벡터
        Vector3 reflecVec   = Vector3.Reflect(incomingVec, normalVec); //반사각

        transform.rotation = Quaternion.LookRotation(reflecVec);

        BeforePos = transform.position; // 이전 위치 갱신

        item.hitCount--;
        if (collision.collider.CompareTag("ENEMY"))
        {
            //Destroy(collision.collider.gameObject);
            EnemyCtrl enemy = collision.collider.GetComponent <EnemyCtrl>();
            enemy.Stop = true;
            //Transform StopPosition = this.gameObject.transform;
            //enemy.target = StopPosition;
            enemy.Invoke("UnStop", 2.0f);

            //Invoke("enemy.GetNextWaypoint()", 2.0f);
            Destroy(transform.gameObject);
            GameManager.Instance.m_cItemManager.DestroyBullet(this.transform, item);
        }

        if (item.hitCount == 0)
        {
            Destroy(transform.gameObject);    //총알로 사용할 경우 4번째 충돌시 파괴
            GameManager.Instance.m_cItemManager.DestroyBullet(this.transform, item);
        }
    }