본문 바로가기

유니티(Unity)/협동 프로젝트

[Unity] 뷰포리아 활용 AR 프로젝트 - 2주차

반응형

 

이 글은 특정 툴을 소개하거나, 사용법, 꿀팁 공유 등을 하는 것이 아닌, 협동 프로젝트 진행 과정을 단순하게 저장해놓은 글입니다. 이러 이러한 것들을 썼지~ 이러 이러한 과정이 있었지 ~ 라는 것을 기억해두기 위해 남겨놓은 글일 뿐입니다.

 


 

이번주는 배경 이미지 타겟에 오브젝트를 띄워서 머지큐브의 좌표계와 배경 이미지 타겟의 좌표계가 동일한 것인지를 확인해줬습니다. 

 

진행하기에 앞서, 머지큐브를 이용하겠다는 계획은 철회하고 일반 이미지를 이용하기로 했습니다.(이미지 자체는 머지큐브의 면들을 이용하겠습니다..)

 

가장 처음에는 먼저, 둘의 좌표를 가져오기!.. 그러기 위해 먼저 배경 이미지 타겟을 하나 추가해줍니다.

 

 

그리고 좌표 로그찍기.

 

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

public class target : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        Debug.Log("MergeImage : " + this.gameObject.transform.position);
    }
}

 

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

public class test : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        Debug.Log("BackgroundImage " + this.gameObject.transform.position);
    }
}

 

그런데, 오브젝트 끼리의 충돌을 테스트해야 했기 때문에 이미지 타겟에서 오브젝트로 함수 실행 위치를 바꿔줬습니다.

 

또 느낀 것이, 이 오브젝트의 좌표계가 월드 좌표계인지 로컬 좌표계인지도 확실히 몰라서 둘의 충돌을 실험시켜 봤습니다.

 

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

public class collobj : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        //Debug.Log("Cat : " + this.gameObject.transform.position);
    }

    /*private void OnCollisionEnter(Collision collision)
    {
        //if (collision.collider.gameObject.CompareTag("Alphabets"))
        //{
            Debug.Log("TTTTTTTYTTTTTTT");
        //}
    }*/

    private void OnTriggerStay(Collider other)
    {
        Debug.Log("TTTTTTTYTTTTTTT");
    }
}

고양이가 움직이면서 닿을 것이기 때문에 고양이에게 스크립트를 추가해줬습니다.

 

Is Trigger를 체크해줘야 한다.

 

로그 출력

 

 

728x90