본문 바로가기
[ CODING STUDY ]/》유니티 실습

유니티 - [마우스 클릭시 게임오브젝트 이동]

by MRG 2023. 10. 5.
728x90
반응형

 

 

▣ 게임오브젝트 생성, player오브젝트에는 스크립트 추가, AttackPos1은 콜라이더 추가

 

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

▣ 마우스 클릭 시 오브젝트 이동코드

 

 

▣ 저장 후 플레이를 해서 AttackPos1을 클릭하면 Player오브젝트 클릭한 오브젝트로 이동

이동할 오브젝트에 콜라이더가 있어야 hit에서 감지

728x90
반응형

'[ CODING STUDY ] > 》유니티 실습' 카테고리의 다른 글

유니티 총알 경로 그리기  (0) 2024.01.14
유니티 photon서버  (0) 2024.01.01
유니티 - [AddForce 종류]  (0) 2023.07.01
유니티 - [충돌시 tag 변경]  (0) 2023.06.20
유니티 - [GetComponent 비활성화]  (0) 2023.06.20

댓글