본문 바로가기

-19

유니티3D, 화면 기준으로 2d 좌표를 3d 좌표로 혹은 반대로 Camera.ScreenToWorldPoint화면 공간의 위치를 월드 공간에 위치로z 값은 카메라의 월드 좌표값을 사용. 1234567891011121314// Draw a yellow sphere in the scene view at the position// on the near plane of the selected camera that is// 100 pixels from lower-left.using UnityEngine;using System.Collections; public class ExampleClass : MonoBehaviour { void OnDrawGizmosSelected() { Camera camera = GetComponent(); Vector3 p = camera.Scre.. 2015. 6. 16.
유니티3D, 게임 오브젝트를 특정 대상을 바라보게 하기 방법1) Quaternion.LookRotation1234567public Transform target;void Update() { Vector3 vec = target.position - transform.position; vec.Normalize(); Quaternion q = Quaternion.LookRotation(vec); transform.rotate = q;}Colored by Color Scriptercs 관련 유니티 문서 #http://docs.unity3d.com/ScriptReference/Quaternion.LookRotation.html 방법2) Transform.LookAt12345public Transform target;void Update() { // Rotate the.. 2015. 5. 26.
유니티3D, 가속도 센서 Input.acceleration - 3차원 공간에서의 기기의 최근 선형 움직임 값을 측정. (읽기전용) 12345678910111213141516using UnityEngine;using System.Collections; public class ExampleClass : MonoBehaviour { public float speed = 10.0F; void Update() { Vector3 dir = Vector3.zero; dir.x = -Input.acceleration.y; dir.z = Input.acceleration.x; if (dir.sqrMagnitude > 1) dir.Normalize(); dir *= Time.deltaTime; transform.Translate(dir * spe.. 2015. 5. 14.
화면에서 마우스 클릭한 위치 Ray 정보, 디버그레이 1234if ( Input.GetMouseButton(0) ) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Debug.DrawRay(ray.origin, ray.direction*100f, Color.red);}Colored by Color Scriptercs 2015. 5. 12.
유니티3D, Mathf 공식 문서 : http://docs.unity3d.com/ScriptReference/Mathf.html Mathf.Abs() Mathf.Acos()Mathf.Asin()Mathf.Atan()Mathf.Atan2() Mathf.Max()Mathf.Min() Mathf.Log()Mathf.Log10() Mathf.Pow() Mathf.Cos()Mathf.Sin()Mathf.Tan() Mathf.Sqrt() 2015. 5. 12.
유니티3D, Invoke함수 MonoBehaviour.Invoke#Invoke http://docs.unity3d.com/ScriptReference/MonoBehaviour.Invoke.html MonoBehaviour.InvokeRepeatinghttp://docs.unity3d.com/ScriptReference/MonoBehaviour.InvokeRepeating.html MonoBehaviour.CancelInvokehttp://docs.unity3d.com/ScriptReference/MonoBehaviour.CancelInvoke.html MonoBehaviour.IsInvokinghttp://docs.unity3d.com/ScriptReference/MonoBehaviour.IsInvoking.html 2015. 4. 9.
320x100