ScreenPointToRay는 기본적으로 카메라 위치에서 마우스 방향을 가리키는 광선을 한다.

 

ScreenToWorldPoint 포인트는 실제로 마우스 아래의 3D 위치를 반환한다.

Vector3 p = camera.ScreenToWorldPoint(new Vector(Input.mousposition.x, 100, camera.nearClipPlane))

가장 이해하기 쉬운 그림이다.
이처럼 카메라와의 높이? 때문에 camera.nearClipPlane  사용한다.

깊이감이 필요한 클릭이라면 레이로 거리 계산을 통해 하는게 좋지만
레이 자체가 정보가 많아 무겁고, 콜라이더도 활용해야 하기 때문에
ScreenToWorldPoint
클릭한 화면의 좌표의 비율을 계산해서 덜 무겁고 활용하기 좋을것 같다.

 

 

 

 

 

https://funfunhanblog.tistory.com/24

 

유니티) ScreenPointToRay 카메라로 부터의 스크린의 점

Camera.ScreenPointToRay 카메라로 부터의 스크린의 점을 통해 레이를 반환합니다. 스크린공간은 픽셀로 정의되며. 픽셀단위 1번 : 왼쪽 하단의 화면이 (0,0) 2번: 오른쪽 상단이 (pixelWidth,pixelHeight) if (In..

funfunhanblog.tistory.com

https://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html

 

Unity - Scripting API: Camera.ScreenToWorldPoint

World space coordinates can still be calculated even when provided as an off-screen coordinate, for example for instantiating an off-screen object near a specific corner of the screen. Screenspace is defined in pixels. The bottom-left of the screen is (0,0

docs.unity3d.com

https://luv-n-interest.tistory.com/828

 

마우스 입력 받아서 이용하는 4가지 방법[Unity]

마우스는 스크린에 있지만 이용하려면 WorldSpace로 변환하던가.. 무엇인가 해야하는 상황이 있다. 마우스 입력을 받아서 이용하는 방법에 대해 알아보자. 0 번째 방법 Input.mousePosition 얘는 그냥 Scre

luv-n-interest.tistory.com

https://gamedev.stackexchange.com/questions/158633/difference-between-unitys-camera-screenpointtoray-and-camera-screentoworldpoint

 

Difference between Unity's Camera.ScreenPointToRay and Camera.ScreenToWorldPoint?

What is the difference between Unity's Camera.ScreenPointToRay and Camera.ScreenToWorldPoint. And where we can use these. I've watched some tutorial and documentation but I didn't get a clear

gamedev.stackexchange.com

https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=dlwhdgur20&logNo=220033708116 

 

[Unity3D] Camera.ScreenToWorldPoint

Camera.ScreenToWorldPoint Vector3 ScreenToWorldPoint(Vector3 position); 게임 화면(Screen...

blog.naver.com

 

'Unity' 카테고리의 다른 글

추가 정리할 목록들  (0) 2022.02.14
Unity 호출순  (0) 2022.01.26
Unity Collider(Collision, Trigger 차이)  (0) 2022.01.21
Unity 드래그 앤 드롭(Drag&Drop)  (0) 2022.01.18

+ Recent posts