본문 바로가기
공부공부/개발경험들! (프로젝트...)

유니티 VR 프로젝트 (포트폴리오?)

by Lee_story_.. 2022. 8. 28.
728x90

교육 프로그램에서 진행한 팀별 vr프로젝트 진행에 대해서 정리한 글입니다!

 

 

우선 사용 프로그램은 스팀 VR 을 이용해 vr기기와 연결을 해보았고

 

 

SteamVR on Steam

Grab SteamVR to access and play VR games using your HTC Vive, Oculus Rift, Windows Mixed Reality headset, or any other supported VR headset and controllers.

store.steampowered.com

 

 

에셋스토어에서 스팀이 제공하는 기본 기능들을 import해서 사용해보았습니다. 

 

SteamVR Plugin | 기능 통합 | Unity Asset Store

Use the SteamVR Plugin from Valve Corporation on your next project. Find this integration tool & more on the Unity Asset Store.

assetstore.unity.com

 

 

 

그리고 

vive vr기기를 사용해보았습니다

 

VIVE 비즈니스한국 - 비즈니스 용 VR

비즈니스를 위한 완벽한 VR 솔루션입니다. 디바이스 관리, 콘텐츠 플랫폼, 소프트웨어, 그리고 서비스를 모두 한 번에 사용할 수 있습니다. 원격 협업, 학습 및 생산성을 최대한 활용하세요.

business.vive.com

 

 

 

 

게임출시를 위한 프로그램이 아닌 학습을 위한 프로젝트로

기존에 유니티에서 제공되는여러 기능들을 모아 만들었습니다

 

 

 

게임에 대해서 설명하자면

 

플레이어 위치에서 각각의 몬스터가 존재하는 포탈을 타고 이동할 수 있는 기능

 

void Update()
    {
        if(Vector3.Distance(player.position, transform.position) < 1f)
        {
            test.enableSpawn = true;
            player.position = telepos.transform.position;

        }

    }

 

 

총 4개의 맵을 만들어 각각 다른몬스터, 다른 공격방식으로 구현해보았습니다.

 

 

 

1스테이지는  몬스터 : 병아리 , 공격방식 : 주먹  

 

2스테이지는  몬스터 : 닭 , 공격방식 : 검

 

3스테이지는  몬스터 : 슬라임 , 공격방식 : 총

 

4스테이지는  몬스터 : 미라 , 공격방식 : 활  

 

 

그리고 몬스터 사망시에는 약간의 튕겨난 다음 사라지는 방법으로 타격감을 좀더 표현해 보았습니다.

 

 

 

 

 

 

다음으로는 스폰으로 인해 포홛되는 몬스터 문제를 위해 

포탈을 타고 이동하면 각 맵의 몬스터가 생성되고

 

 

void Start()
    {
        SpawnPosList = new Transform[transform.childCount];
        for (int i = 0; i < transform.childCount; i++)
        {
            SpawnPosList[i] = transform.GetChild(i);
        }

        InvokeRepeating("SpawnEnemy", 3, 3);
    }

    void SpawnEnemy()
    {
        Vector3 randomPos = SpawnPosList[Random.Range(0, SpawnPosList.Length)].position;

        if (enableSpawn && safe == false)
        {
            GameObject zombie = (GameObject)Instantiate(zombiePrefab, randomPos, Quaternion.identity);
            zombie.GetComponent<enemy>().SafeArea = SafeArea;

            //CancelInvoke();
        }
    }

    // Update is called once per frame
    void Update()
    {
        SafeAreaDistance = Vector3.Distance(SafeArea.transform.position,
            new Vector3(Camera.main.transform.position.x, 0, Camera.main.transform.position.z));
        safe = (SafeAreaDistance < 0.3f) ? true : false;
    }

 

 

 

각 맵을 탈출하여 마을로 돌아왔을때에는 모든 몬스터 태그를 가진 존재들을 삭제해 주었습니다.

 

public SpawnManager1 test1;
    public SpawnManager2 test2;
    public SpawnManager3 test3;
    public SpawnManager4 test4;

    public PopupControl hand;


    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (Vector3.Distance(player.position, transform.position) < 1f)
        {

            player.position = telepos.transform.position;
            test1.enableSpawn = false;
            test2.enableSpawn = false;
            test3.enableSpawn = false;
            test4.enableSpawn = false;

            hand.HideGun();
            hand.Hidesword();


            Destroy_M();
            
        }

    }

    void Destroy_M()
    {
        GameObject[] monsta = GameObject.FindGameObjectsWithTag("Monsta");

        for(int i = 0; i < monsta.Length; i++)
        {
            Destroy(monsta[i]);
        }
    }
}

 

 

 

그리고 총 몬스터 처치수를 측정하여 마을뒤편에 표시해 주었습니다

 

 

text_2.text = "Kill Count\n\n\n" + M_1.ToString();

 

 

 

 

 

 

 

 

 

댓글