'2014/02/03'에 해당되는 글 4건

  1. 2014.02.03 글자 크기를 점점 커지게 하면서 사라지게 하기
  2. 2014.02.03 게임 매니저에서 FSM 으로 게임 분기 처리하기
  3. 2014.02.03 충돌 처리시 Tag 설정 값 파악하기
  4. 2014.02.03 Quaternion.LookRotation

글자 크기를 점점 커지게 하면서 사라지게 하기

|




히어라이키 탭에 "txtMsg" GUI text 생성 해야됨.



Trackback 0 And Comment 0

게임 매니저에서 FSM 으로 게임 분기 처리하기

|
각각의 스크립트가 게임 매니저와 동기를 유지하려면 게임의 상태를 표시하는 변수가 필요합니다. 보통 게임 매니저 스크립트의 위와 같이 변수들을 선언하고 업데이트 문에서 해당하는 변수에 따라 분기 처리를 하여 게임을 관리해줍니다.
Trackback 0 And Comment 0

충돌 처리시 Tag 설정 값 파악하기

|


C# 에서는 스위치 문에서도 string의 사용이 가능합니다.

충돌시 충돌하는 물체에 각각 Tag 값을 넣어서 구별을 할수 있습니다.

만약 


ENEMY, BONUS 등 태그값을 구분하려면 아래 처럼 하면 됩니다.

참고로 태그를 지정하지 않은 값들은 모두 Untagged 값을 가지는데 이것또한 태그값입니다.

마찬가지로 태그로 구별할수 있습니다.


void OnTriggerEnter(Collider coll){

switch(coll.tag)

{

case "ENEMY":

//충돌 처리 로직

break;

cae "BONUS":

//충돌 처리 로직

break;

case "Untagged"

//충돌 처리 로직 (태그값을 지정하지 않은 물체)

break;

    }

}


OnTriggerEnter 는 두 물체 중에 하나가 isTrigger 속성이 On으로 설정이 되어야 하며 두물체중 하나는 리지드바디가 추가되어야 발동되는

함수입니다.


Trackback 0 And Comment 0

Quaternion.LookRotation

|

두 점 사이의 각도를 계산할때 사용하는 API 함수

static Quaternion LookRotation(Vector3 forward, Vector3 upwards = Vector3.up);


forward는 바라보는 물체 

upwards는 기본값이 Vector3.up으로 정의되있음.






Quaternion.LookRotation

static Quaternion LookRotation(Vector3 forwardVector3 upwards = Vector3.up);
Parameters

forwardThe direction to look in.
upwardsThe vector that defines in which direction up is.
Description

Creates a rotation with the specified forward and upwards directions.

Returns the computed quaternion. If used to orient a Transform, the Z axis will be aligned with forward and the Y axis withupwards if these vectors are orthogonal. Logs an error if the forward direction is zero.
using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour {
    public Transform target;
    void Update() {
        Vector3 relativePos = target.position - transform.position;
        Quaternion rotation = Quaternion.LookRotation(relativePos);
        transform.rotation = rotation;
    }
}
See Also: SetLookRotation.


Trackback 0 And Comment 0
prev | 1 | next