How to get Mouse Position in 3D and 2D! (Unity Tutorial)

Аватар автора
Вдохновение JavaScript
? Learn to make awesome games step-by-step from start to finish. ? One of the comments I get a lot is people asking why the code shown in the video isn&working, and usually the reason is because in the video I showcase some system working in 2D and they&trying to get it to work in 3D. It&pretty simple to get the mouse position in 3D but it is a completely different method compared to 2D. So here let&see how both methods work and why they need to be different. 2D: Camera.main.ScreenToWorldPoint(Input.mousePosition); 3D: Physics.Raycast(Camera.main.ScreenToRay(Input.mousePosition, out RaycastHit raycastHit)); ? Get Code Monkey on Steam! ? Interactive Tutorials, Complete Games and More! If you have any questions post them in the comments and I&do my best to answer them. See you next time! #indiedev -------------------------------------------------------------------- Hello and Welcome! I&your Code Monkey and here you will learn everything about Game Development in Unity using C#. I&been developing games for several years with 8 published games on Steam and now I&sharing my knowledge to help you on your own game development journey. I do Unity Tutorials on just about every topic, Unity Tutorials for Beginners and Unity Tutorials for Advanced users. -------------------------------------------------------------------- - Other great Unity channels: --------------------------------------------------------------------

0/0


0/0

0/0

0/0