Unity
-
Unity - Rigidbody.AddForceUnity 2021. 3. 20. 11:50
2020.11.11 - Unity - Rigidbody 마우스로 상하좌우 튕기기 public Vector3[] mMouseDrag = new Vector3[2]; //... Quaternion qtr = cam.transform.rotation; qtr.x = 0; qtr.Normalize(); Vector3 md = mMouseDrag[1]-mMouseDrag[0]; Vector3 fh = cam.transform.right * md.x/Screen.width, //fv = cam.transform.up * md.y/Screen.height; fv = (qtr * Vector3.forward) * md.y/Screen.height; Vector3 fu = Vector3.up * Mathf.Abs(Vec..
-
Unity - Mouse (object event)Unity 2021. 3. 20. 00:42
2021.03.18 - Unity - Mouse(Input class) Mouse Down void OnMouseDown() { Debug.Log(" OnMouseDown"); } Mouse Up void OnMouseUp() { Debug.Log(" OnMouseUp"); } Mouse Drag void OnMouseDrag() { Debug.Log(" OnMouseDrag"); } Ex: 3d object drag 1 void OnMouseDrag() { float spz = Camera.main.WorldToScreenPoint(transform.position).z; Vector3 v3 = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePositi..
-
Unity - RayUnity 2021. 3. 19. 22:17
Hit RaycastHit hit; Ray ray = mCam.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { Transform hitobj = hit.transform; Debug.Log("hit x:" + hit.point.x + " y:" + hit.point.y + " z:" + hit.point.z); Debug.Log("obj n:" + hitobj.name + " x:" + hitobj.position.x + " y:" + hitobj.position.y + " z:" + hitobj.position.z); }
-
Unity - Mouse (Input class)Unity 2021. 3. 18. 21:43
2021.03.20 - Unity - Mouse(object event) Ex 눌려짐 감지 void Update() { // ... if (Input.GetButton("Fire1")) { Vector3 pos = Input.mousePosition; Debug.Log(" mose x:" + pos.x + " y:" + pos.y); } // ... } Button 상태 GetButton GetButtonDown GetButtonUp Button 종류 Fire1: 왼쪽 버튼, 또는 Ctrl Fire2: 오른쪽 버튼, 또는 Alt Fire3: 중간 버튼, 또는 Shift Zoom In/Out void Update() { if (Input.GetButton("Fire1")) { Ray ray = mCam.S..