VR 테마파크 프로젝트 스터디 (4기 부산/경남)

참여인원 : 50명

모임일정 : 2017년 3월 25일 ~ 8개월 (월 2회, 토요일 오후 2시~5시, 3시간, 간혹 운영자 개인 사정으로 일요일 및 시간 변경될 수 있음)

모임장소 : 아지트가 없는 관계로 수시로 변경 ㅡㅡ;

스터디 : VR SDK(이경용), 유니티5 (정현철), 언리얼 (정현철), 아두이노 및 센서개발 (이상협), 블렌드 3D (조현퇴), 3D프린트 (조현퇴)

프로젝트 : 실내 공간에서 여러명이서 고스트를 잡는 콘텐츠 개발, VR과 연동하는 하드웨어 장치, 실내에서 유저의 위치 파악하는 센스 등 개발, AR 스마트 팽이

준비물 : 노트북, 유니티5 설치 (아두이노 외 센서 부품 등)

모임문의 : 이경용 010-2694-8424 / ceo@apptools.co.kr

부운영자 및 멘토 :  정현철, 이상협, 박대웅, 조현퇴

4기 부산/경남

[VR검투사]8일차

페이지 정보

작성자 손호준 작성일17-06-28 18:58 조회2,004회 댓글0건

첨부파일

본문

-손호준-

어제 만들던 고양이 게임의 컨텐츠를 추가 시켰습니다.

일단 떨어지는 폭탄이 랜덤한 시간으로 터지게 만들고 폭팔 파티클을 추가하였습니다.

 count = Random.Range(0f, 5f);

 StartCoroutine("Explosion", count);

GameObject exp = (GameObject)Instantiate(expEffect, tr.position, Quaternion.identity);


그리고 적을 만들어서 플레이어를 쫒아 오게 만들고 닿이면 체력이 많이 까지게 만들었습니다.
적은 Nav Mesh Agent 를 이용해 땅을 Navigation Static 설정을 하고 Bake를 한 후
코드를 이용해 Player의 위치를 읽어서 쫒아 오게 만들었습니다.
그리고 시간이 경과 할수록 점점더 빨라 지도록 했습니다.
Rigidbody ri;
Vector3 v3;
public GameObject player;

NavMeshAgent nav;

void Awake () {
ri = GetComponent<Rigidbody>();
nav = GetComponent<NavMeshAgent>();

//시작할때 랜덤위치에서 생성
v3.x = Random.Range(-49f, 49f);
v3.y = 1f;
v3.z = Random.Range(-49f, 49f);
ri.MovePosition(v3);
}
private void Update()
{
nav.SetDestination(player.transform.position);
if(TimeUpdate.time < 20f) // 시간이 20초보다 낮으면 원래 속도 그대로 쫒게 만듬
{
 return;
}
else // 시간이 20초가 넘으면 점점더 빨라짐
{
nav.speed = (TimeUpdate.time / 2);
}
}

그리고 힐킷(HealKit)를 만들어 닿이면 체력이 1이 채워지게 만들었습니다.
그리고 동적인 움직임을 추가하기 위해 옆으로 돌아가면서 위아래로 움직이게 만들어서
둥둥 떠있는 느낌을 주었습니다.
Transform tr;
    Vector3 v3;
    GameObject player;
    bool updown = true;

    private void Awake()
    {
        tr = GetComponent<Transform>();
        player = GameObject.FindGameObjectWithTag("Player");
    }

    private void Update()
    {
        tr.Rotate(0f, 1f, 0f);
        v3.x = tr.position.x;
        v3.z = tr.position.z;
        if(updown)
        {
            if (tr.position.y <= 1f)
            {
                updown = false;
            }
            v3.y = (tr.position.y - 0.02f);
            tr.position = v3;
        }
        else
        {
            if (tr.position.y >= 2f)
            {
                updown = true;
            }
            v3.y = (tr.position.y + 0.02f);
            tr.position = v3;
        }
    }

    private void OnTriggerEnter(Collider other)
    {
        if (player)
        {
            Destroy(this.gameObject);
            PlayerCtr.hp++;
        }
    }

EmptyObject를 만들어 HealKitCreate라 이름지은 후 랜덤한 위치로 이동해 힐킷을 생성하게 만들었습니다.
void Start()
    {
        tr = GetComponent<Transform>();
        rigidbody = GetComponent<Rigidbody>();
        v3.x = Random.Range(-49f, 49f);
        v3.y = 1.5f;
        v3.z = Random.Range(-49f, 49f);
        rigidbody.MovePosition(v3);
        StartCoroutine("HealKitCreat", delay);
    }

    IEnumerator HealKitCreat(float delay)
    {
        yield return new WaitForSeconds(delay);
        v3.x = Random.Range(-49f, 49f);
        v3.y = 1.5f;
        v3.z = Random.Range(-49f, 49f);
        rigidbody.MovePosition(v3);
        Instantiate(healKit, tr.position, tr.rotation);
        StartCoroutine("HealKitCreat", delay);
    }

-성기헌-



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MapGenerator : MonoBehaviour {

    public Map[] maps;
    public int mapIndex;

    public Transform tilePrefab;
    public Transform obstaclePrefab;
    public Transform navmeshFloor;
    public Transform navmeshMaskPrefab;
    
    public Vector2 maxMapSize;

    [Range(0,1)]
    public float outlinePercent;
    
    public float tileSize;

    List<Coord> allTileCoords;
    Queue<Coord> shuffledTileCoords;

    Map currentMap;
  
   

    void Start()
    {
        GenerateMap();
            }
    public void GenerateMap()
    {
        System.Random prng = new System.Random(currentMap.seed);
        currentMap = maps[mapIndex];
        GetComponent<BoxCollider>().size = new Vector3(currentMap.mapSize.x * tileSize, .05f, currentMap.mapSize.y * tileSize);

        // Generating coords
        allTileCoords = new List<Coord>();
        for (int x = 0; x < currentMap.mapSize.x; x++)
        {
            for (int y = 0; y < currentMap.mapSize.y; y++)
            {
                allTileCoords.Add(new Coord(x, y));


            }
        }

        shuffledTileCoords = new Queue<Coord>(Utility.ShuffleArray(allTileCoords.ToArray(), currentMap.seed));
        
        
        // Create map holder object
        string holderName = "Generated Map";
        if (transform.FindChild(holderName))
        {
            DestroyImmediate(transform.FindChild(holderName).gameObject);
        }
        Transform mapHolder = new GameObject(holderName).transform;
        mapHolder.parent = transform;

        // Spawning tiles
        for(int x = 0; x< currentMap.mapSize.x; x++)
        {
            for(int y =0; y< currentMap.mapSize.y; y++)
            {
                Vector3 tilePosition = CoordToPosition(x, y);
                Transform newTile = Instantiate(tilePrefab, tilePosition, Quaternion.Euler(Vector3.right * 90)) as Transform;
                newTile.localScale = Vector3.one * (1 - outlinePercent);
                newTile.parent = mapHolder;
            }
        }
        // Spawning obstacles
        bool[,] obstacleMap = new bool[(int)currentMap.mapSize.x, (int)currentMap.mapSize.y];

        int obstacleCount = (int)(currentMap.mapSize.x * currentMap.mapSize.y * currentMap.obstaclePercent);
        int currentObstacleCount = 0;

        for (int i = 0; i < obstacleCount; i++)
        {
            Coord randomCoord = GetRandomCoord();
            obstacleMap[randomCoord.x, randomCoord.y] = true;
            currentObstacleCount++;

            if (randomCoord != currentMap.mapCentre && MapIsFullyAccessible(obstacleMap, currentObstacleCount))
            {
                float obstacleHeight = Mathf.Lerp(currentMap.minObstacleHeight, currentMap.maxObstacleHeight, (float)prng.NextDouble());
                Vector3 obstaclePosition = CoordToPosition(randomCoord.x, randomCoord.y);
                Transform newObstacle = Instantiate(obstaclePrefab, obstaclePosition + Vector3.up * obstacleHeight/2, Quaternion.identity) as Transform;
                newObstacle.parent = mapHolder;
                newObstacle.localScale = new Vector3((1 - outlinePercent)*tileSize, obstacleHeight,(1 - outlinePercent)*tileSize);

                Renderer obstacleRenderer = newObstacle.GetComponent<Renderer>();
                Material obstacleMaterial = new Material(obstacleRenderer.sharedMaterial);
                float colourPercent = randomCoord.y / (float)currentMap.mapSize.y;
                obstacleMaterial.color = Color.Lerp(currentMap.foregroundColour, currentMap.backgroundColour, colourPercent);
                obstacleRenderer.sharedMaterial = obstacleMaterial;
            }
            else
            {
                obstacleMap[randomCoord.x, randomCoord.y] = false;
                currentObstacleCount--;
            }
        }

        //Creating navmesh mask
        Transform maskLeft = Instantiate(navmeshMaskPrefab, Vector3.left * (currentMap.mapSize.x + maxMapSize.x) / 4f * tileSize, Quaternion.identity) as Transform;
        maskLeft.parent = mapHolder;
        maskLeft.localScale = new Vector3((maxMapSize.x - currentMap.mapSize.x) / 2, 1, currentMap.mapSize.y) * tileSize;

        Transform maskRight = Instantiate(navmeshMaskPrefab, Vector3.right * (currentMap.mapSize.x + maxMapSize.x) / 4 * tileSize, Quaternion.identity) as Transform;
        maskRight.parent = mapHolder;
        maskRight.localScale = new Vector3((maxMapSize.x - currentMap.mapSize.x) / 2, 1, currentMap.mapSize.y) * tileSize;

        Transform maskTop = Instantiate(navmeshMaskPrefab, Vector3.forward * (currentMap.mapSize.x + maxMapSize.x) / 4 * tileSize, Quaternion.identity) as Transform;
        maskTop.parent = mapHolder;
        maskTop.localScale = new Vector3(maxMapSize.x, 1, (maxMapSize.y - currentMap.mapSize.y) / 2) * tileSize;

        Transform maskButtom = Instantiate(navmeshMaskPrefab, Vector3.back * (currentMap.mapSize.x + maxMapSize.x) / 4 * tileSize, Quaternion.identity) as Transform;
        maskButtom.parent = mapHolder;
        maskButtom.localScale = new Vector3(maxMapSize.x,1,(maxMapSize.y-currentMap.mapSize.y)/2) * tileSize;

        navmeshFloor.localScale = new Vector3(maxMapSize.x, maxMapSize.y) * tileSize;
    }
    bool MapIsFullyAccessible(bool[,] obstacleMap, int currentObstacleCount)
    {
        bool[,] mapFlags = new bool[obstacleMap.GetLength(0), obstacleMap.GetLength(1)];
        Queue<Coord> queue = new Queue<Coord>();
        queue.Enqueue(currentMap.mapCentre);
        mapFlags[currentMap.mapCentre.x, currentMap.mapCentre.y] = true;
        int accessibleTileCount = 1;
        while (queue.Count > 0)
        {
            Coord tile = queue.Dequeue();
            for(int x = -1; x<=1; x++)
            {
                for (int y = -1; y <= 1; y++)
                {
                    int neighbourX = tile.x + x;
                    int neighbourY = tile.y + y;
                    if (x == 0|| y == 0)
                    {
                        if(neighbourX >= 0 && neighbourX < obstacleMap.GetLength(0)&& neighbourY >= 0 && neighbourY < obstacleMap.GetLength(1))
                        {
                            if(!mapFlags[neighbourX,neighbourY]&& !obstacleMap[neighbourX, neighbourY])
                            {
                                mapFlags[neighbourX, neighbourY] = true;
                                queue.Enqueue(new Coord(neighbourX, neighbourY));
                                accessibleTileCount++;
                            }
                        }
                    }


                }
            }
        }
        int targetAccessibleTileCount = (int)(currentMap.mapSize.x * currentMap.mapSize.y - currentObstacleCount);
        return targetAccessibleTileCount == accessibleTileCount;
    }
   
    Vector3 CoordToPosition(int x, int y) {
        return new Vector3(-currentMap.mapSize.x / 2f + 0.5f + x, 0, -currentMap.mapSize.y / 2f + 0.5f + y) * tileSize;
    }
    public Coord GetRandomCoord()
    {
        Coord randomCoord = shuffledTileCoords.Dequeue();
        shuffledTileCoords.Enqueue(randomCoord);
        return randomCoord;
    }
    public struct Coord
    {
        public int x;
        public int y;
        public Coord(int _x, int _y)
        {
            x = _x;
            y = _y;
        }
        public static bool operator ==(Coord c1, Coord c2)
        {
            return c1.x == c2.x && c1.y == c2.y;
        }
        public static bool operator !=(Coord c1, Coord c2)
        {
            return !(c1 == c2);
        }
    }
    [System.Serializable]
    public class Map
    {
        public Coord mapSize;
        [Range(0, 1)]
        public float obstaclePercent;
        public int seed;
        public float minObstacleHeight;
        public float maxObstacleHeight;
        public Color foregroundColour;
        public Color backgroundColour;

        public Coord mapCentre
        {
            get
            {
                return new Coord(mapSize.x / 2, mapSize.y / 2);
            }
        }
    }
}
기존에 있던 캐릭터생성부분은 나두고 새로운 Map을 만들어서 Editor을 이용한 크기조절과 랜덤으로 장애물 생성하게 만들었습니다. 그리고 Nevigator을 이용해 적 캐릭터가 추적 가능하게 만들었고 장애물 생성시 발생되는 색깔을 설정했습니다.

-이성현 조충진-
아두이노 실습의 마지막날로써 들고 있는 아두이노의 모듈들을 대부분 다 한번씩 꼽아보았습니다 모듈을 활용하는 소스들을 이해하는데 시간이 걸렸지만 하나하나 뜯어가며 생각하고 VR검투사 프로젝트에 이 것을 어떻게 적용시킬 것 인지를 생각하며 모듈들을 구현해 보았습니다 그중 하나인 조충진이 구현한 LED전구 모듈을 삼색으로 변경시키는 소스를 올립니다
#define RED 11
#define GREEN 10
#define BLUE 9

void setup() {
  randomSeed(analogRead(0));

}

void loop() {
  analogWrite(RED,random(255));
  analogWrite(GREEN,random(255));
  analogWrite(BLUE,random(255));
  delay(1000);

}
동영상 첨부합니다

-서정호-

오늘은 어제 하던작업의 마무리작업입니다 추가컨텐츠로 캐릭터의 점프와 장애물을 늘리고 박스를만들어 배럴과 비슷하게보여 난이도를 올렷습니다 그리고 게임을 시작한지 알기위해 시간이 나오게 표기를 하였고 캐릭터의 세부작업을 하엿습니다 마무리로 배럴이 다부서지면 게임종료를 할수있게하려고 하였으나 아직 미숙한 지식으로 하기엔 모자랐던 작업이어서 아직 마무리를 다못햇습니다.

d
  • 페이스북으로 보내기
  • 트위터로 보내기
  • 구글플러스로 보내기

* 글을 등록하실때 꼭 필요한 경우가 아니면 개인정보를 남기지 마세요 ^^ (연락처,이메일주소,주민등록번호 등)





  최면중... 당신은 곧 코멘트를 달게 됩니다...수리수리 뽀로롱..

댓글목록

등록된 댓글이 없습니다.

4기 부산/경남 목록

Total 38건 1 페이지
4기 부산/경남 목록
번호 제목 글쓴이 날짜 조회
38 [VR검투사]18일차 인기글 손호준 07-12 2225
37 [VR검투사]17일차 인기글첨부파일 손호준 07-11 2260
36 [VR 검투사] 16일차 인기글 손호준 07-10 2308
35 [VR검투사] 15일차 인기글첨부파일 손호준 07-07 2258
34 [VR검투사] 14일 차 인기글첨부파일 손호준 07-06 2324
33 [VR검투사] 13일차 인기글첨부파일 손호준 07-05 2652
32 [VR검투사] 12일차 인기글첨부파일 손호준 07-04 2047
31 [VR검투사]11일차 인기글첨부파일 손호준 07-03 1976
30 [VR검투사]10일차 인기글첨부파일 손호준 06-30 1799
29 [스마트팽이]10일차 인기글 모진원 06-30 1724
28 [VR검투사]9일차 인기글첨부파일 손호준 06-29 2105
27 [스마트팽이]9일차 인기글첨부파일 모진원 06-29 1704
열람중 [VR검투사]8일차 인기글첨부파일 손호준 06-28 2005
25 [스마트팽이]8일차 인기글 이정목 06-28 1705
24 [VR검투사] 7일차 인기글첨부파일 손호준 06-27 1748
23 [VR검투사] 6일차 인기글첨부파일 손호준 06-26 1688
22 [VR검투사] Unity학습5 인기글 조충진 06-23 1684
21 [스마트팽이팀]5일차 인기글첨부파일 모진원 06-23 1772
20 [VR검투사] Unity 학습4 인기글 성기헌 06-22 1884
19 [스마트 팽이]4일차 인기글첨부파일 모진원 06-22 1793
게시물 검색
모바일 버전으로 보기