2015년 5월 27일 수요일

Unity Device Check(디바이스 알아내기)

private void CheckDevice()
    {
        if (Application.platform == RuntimePlatform.Android)
        {
            //안드로이드
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            //아이폰
        }
        else if (Application.platform == RuntimePlatform.WindowsEditor)
        {
            //PC 디버깅
        }

    }

2015년 5월 19일 화요일

Unity Rotate

///////////////////////////////////////////////////////////////////////////////////////////////////

1. 목표가 되는 방향 벡터가 있을때( 한 지점(position)도 마찬가지)

목표벡터 direction(노말라이즈 해서 씁니다.)

float rs = 10.0f * Time.deltaTime ;//(rotateSpeed);

 Vector3 newDir = Vector3.RotateTowards(transform.forward, direction, rs, 0.0f);

transform.rotation = Quaternion.LookRotation(newDir);


2. 회전각이 있을때
transform.Rotate(Vector3.up * Time.deltaTime * rotateSpeed);

3. vector3를 quaternion으로
Quaternion rotation = Quaternion.Euler(0, 30, 0);

4. quaternion을 vector3로
vector3 v3 = someObjectTransform.rotation.eulerAngles


5. 백터의 회전
vector = Quaterinon(rotationVector) * vector;