示例#1
0
文件: Gun.cs 项目: epord/ITBAGameJam
    private void shoot()
    {
        shootingLine.SetPosition(0, gunMesh.transform.position);
        soundsManager.PlayShoot();
        int        playerLayerMask = 1 << 8;
        RaycastHit hit;

        if (Physics.Raycast(gunMesh.transform.position, raycastDirection, out hit, Mathf.Infinity, ~playerLayerMask))
        {
            shootingLine.SetPosition(1, hit.point);

            if (hit.transform.gameObject.tag == "ShootingTarget")
            {
                Destroy(hit.transform.gameObject);
                Debug.Log("Target!!");
            }
            else
            {
                Debug.Log("Wall...");
            }
        }
        else
        {
            shootingLine.SetPosition(1, raycastDirection * 100000);
        }
    }