반응형

Unity 6

3D 카메라(Perpendicular Projection)에서 ScreenToWorldPoint() 가 Input.mousePosition을 제대로 잡지 못하는 이유

3D 카메라 (perpendicular projection) 에서 ScreenToWorldPoint() 함수는 Vector3를 인자로 받는데, Vector3의 x,y값은 스크린 좌표이고, z값은 카메라로부터의 거리를 나타낸다. 만약 z값이 0이라고 한다면 카메라로부터의 거리가 0이므로 카메라의 위치를 나타내게 된다. 카메라로부터의 거리를 나타내는 카메라 object의 z값을 인자로 지정해주어야 제대로 동작한다. 예를 들어서 카메라의 위치가 (10, 2, -10) 이라고 한다면 camera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10f)); 위와 같은 코드를 작성해 주어야 한다. Reference: https..

개발메모/Unity 2023.10.23

Unpack vs Unpack Completely

Prefab으로 되어있는 gameObject를 Unpack 할때 볼 수 있는 두가지 옵션, Unpack과 Unpack Completely의 차이는 해당 Object가 하위에 또 다른 Prefab을 갖고 있는지 여부에 따라 다르다. 다음과 같이 ParentPrefab 하위에 ChildPrefab이 있는 경우에 Unpack을 진행해보면 1. Unpack을 실행할 경우 ChildPrefab은 unpack되지 않은 것을 확인 할 수 있다. 2. Unpack Completely를 실행할 경우 ParentPrefab, ChildPrefab 모두 Unpack된 것을 확인 할 수 있다. 다음과 같이 다른 결과를 볼 수 있다.

개발메모/Unity 2023.09.13

OnTriggerEnter2D 함수가 동작하지 않는 이유

OnTriggerEnter2D 의 공식 문서를 보면 다음과 같은 설명을 볼 수 있다. Description Sent when another object enters a trigger collider attached to this object (2D physics only). Further information about the other collider is reported in the Collider2D parameter passed during the call. This message is sent to the trigger Collider2D and the Rigidbody2D (if any) that the trigger Collider2D belongs to, and to the Rigidbod..

개발메모/Unity 2023.08.07
반응형