Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

브래의 슬기로운 코딩 생활

모바일 게임 실무 기말고사 정리 본문

2-2/모바일 게임 실무

모바일 게임 실무 기말고사 정리

김브래 2023. 12. 6. 22:30

모바일 게임 실무 기말고사

202114013 김동현

 

? = GetComponentInParent<CharacterController>(); // 부모 객체의 구성요소 사용

 

vrCamera.eulerAngles.x: x축으로 기울어진 각도

vrCamera.TransformDirection:월드축 방향

(CharacterController객체).SimpleMove(방향, 속도)

: 캐릭터의 속도 값을 받아 그 방향으로 이동시키는 함수

 

public void OnPointerEnter() // 카메라가 객체를 바라봤을 때

public void OnPointerExit() // 카메라가 객체를 바라보다가 바라보지 않을 때

스크립트이름 . 인스턴스 = ? // 해당 스크립트 인스턴스 호출 가능

 

StartCoroutine(); // 코루틴 시작 (인자가 있는 코루틴은 함수 자체를 호출)

StopAllCoroutines(); // 모든 코루틴 종료

StopCoroutine()함수의 인자에 코루틴 함수명을 문자열로 넣으면 코루틴이 종료가 된다.

하지만 코루틴 함수를 그대로 넣으면 코루틴 함수가 멈추지 않는다.

 

IEnumerator // 코루틴 선언 키워드

1) yield return null // 다음 프레임까지 대기

2) yield return new WaitForSeonds( float time ) // 지정된 time초만큼 대기

3) yield return new WaitForEndOfFrame() // 모든 렌더링 작업이 끝날 때가지 대기

 

RaycastHit hit; // 레이저에 닿을 객체 hit변수 선언

if(Physics.Raycast(transform.position, transform.forward, out hit, _maxDistance))

// 만약 객체의 위치에서 앞으로 최대거리까지 레이저를 쏴서 hit(레이저에 닿은 객체)이 있다면

if(Physics.Raycast(<시작위치>, <방향>, out hit, <거리>))

 

if(hit.transform.gameObject.name == "A") // 만약 hit의 이름이 A라면

(GameObject변수).SendMessage("OnPointerEnter");

// GameObject에게 OnPointerEnter 신호를 보냄 (해당 함수 호출)

 

Animator anim; // Animator 변수 선언

anim = GetComponent<Animator>(); // 해당 객체에 Animator 컴포넌트를 넣음

anim.Play("");// 해당 애니메이션 재생

 

Video Player를 이용하여 동영상 재생

// Play On Awake : 시작하자마자 재생

// Loop: 반복

 

Audio Source를 이용하여 소리를 재생

// Play On Awake : 시작하자마자 재생

// Loop: 반복

 

 

 

public VideoClip clip01;

public GameObject Sphere1;

public Button button;

 

if (hit.transform.gameObject.name =="Button") // 만약 hit의 이름이 “Button”이라면

button.GetComponent<Image>().color = Color.blue;

// 버튼 객체의 이미지 색상을 파랑으로 변경

Sphere1.GetComponent<VideoPlayer>().clip = clip01;

// Sphere1의 비디오 클립을 clip01로 설정 (해당 영상 재생)

(비디오와 음성이 같이 나오게 하려면 Video Player 컴포넌트의 Audio Source에 추가한 Audio Source 컴포넌트를 넣어준다. )

 

while (head.transform.position != pos.transform.position)

// head 객체와 pos1의 위치가 같아질 때 까지

head.transform.position =

 

public static Vector3.MoveTowards([자신의 위치], [목표 위치], [프레임 당 이동할 거리])

Vector3.MoveTowards(head.transform.position, pos1.transform.position, Time.deltaTime)

// head객체의 위치에서 pos1 객체의 위치로 Time.deltaTime 속도로 이동

 

door.transform.rotation=

Quaternion.Slerp(door.transform.rotation, Quaternion.Euler(?, ??, ???), Time.deltaTime)

// door객체가 Time.deltaTime 속도로 Quaternion.Euler(?, ??, ???) 각도로 회전함

 

Vector3 forward = transform.TransformDirection(Vector3.forward) * 1000;

// forward 선언

if(Physics.Raycast(transform.position, forward, out hit))

// 만약 객체의 위치에서 앞으로 레이저를 쏴서 hit(레이저에 닿은 객체)이 있다면

if (hit.collider.name == “?”) // 만약 hit 객체의 충돌체의 태그 이름이 ? 라면

Debug.DrawRay(transform.position, forward, Color.green);

// 객체 위치에서 앞으로 초록색 선을 그린다.

 

Vector2 screenSize = new Vector2(Screen.width * 0.5f, Screen.height * 0.5f);

// 스크린 중앙 지점을 저장

 

public GameObject indicator; // 표식

ARRaycastManager arManager;

List<ARRaycastHit> hitInfos = new List<ARRaycastHit>();

//Ray에 부딪힌 대상들을 저장할 리스트 변수 선언

if (arManager.Raycast (screenSize, hitInfos, TrackableType.Planes))

// 만약 스크린 중앙 지점에서 레이를 발사하였을 때 Plane 타입 추적 대상이 있다면

indicator.SetActive (true); // 표식 오브젝트를 활성화

 

Input.touchCount // 모바일 화면에 접촉되어 있는 손가락의 갯수

Input.GetTouch(0) // 첫번째 입력된 터치 정보를 저장

 

TouchPhase.Began: 터치 시작

TouchPhase.Moved: 터치 후 움직임 (드래그)

TouchPhase.Ended: 터치 그만함

if(Input.touchCount > 0)// 만약, 터치 된 곳이 1개 이상이라면

Touchtouch = Input.GetTouch(0);//터치된 정보 저장

if(touch.phase == TouchPhase.Moved) // // 만약, 터치 후 드래그 중이라면...

 

Ray ray = newRay(Camera.main.transform.position, Camera.main.transform.forward);

// 메인카메라에서 앞으로 발사하는 ray선언

RaycastHit hitInfo; // ray에 닿은 객체

if(Physics.Raycast(ray, out hitInfo, Mathf.Infinity, 1 << 8))

// hitinfo8번 레이어에 있다면

Vector3 deltaPos = touch.deltaPosition // x축의 터치 이동량을 구한다.

transform.Rotate(transform.up, deltaPos.x * -1.0f);

// x축의 터치 이동량에 비례하여 로컬 y축 방향으로 회전 (- 시계방향)

 

RotateAround // object의 중심 축 기준으로 회전

trasform.RotateAround(중심점, 회전축, 회전각도);

 

회전축

Vector3.up: y축의 양의 방향

Vector3.down: y축의 음의 방향

Vector3.forward: z축의 양의 방향

Vector3.backward 또는 Vector3.back: z축의 음의 방향

Vector3.right: x축의 양의 방향

Vector3.left: x축의 음의 방향

 

private Transform tr;//지구

public Transform targetTr;//원의 중심점

public float rotSpeed= 15.0f;

tr = GetComponent<Transform>(); // Transform 컴포넌트 추가

tr.RotateAround(targetTr.position, Vector3.up, Time.deltaTime * rotSpeed);

// 원의 중심점을 기준으로 rotSpeed만큼의 속도로 Y축을 기준으로 시계 방향으로 돈다.