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

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

Channel:
Subscribers:
566,000
Published on ● Video Link: https://www.youtube.com/watch?v=0jTPKz3ga4w



Category:
Tutorial
Duration: 10:20
117,127 views
3,714


🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Games https://unitycodemonkey.com/gamebundle

💬 One of the comments I get a lot is people asking why the code shown in the video isn't working, and usually the reason is because in the video I showcase some system working in 2D and they're trying to get it to work in 3D.
It's pretty simple to get the mouse position in 3D but it is a completely different method compared to 2D.
So here let's 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!
https://store.steampowered.com/app/1294220/

If you have any questions post them in the comments and I'll do my best to answer them.

🔔 Subscribe for more Unity Tutorials https://www.youtube.com/channel/UCFK6NCbuCIVzA6Yj1G_ZqCg?sub_confirmation=1

See you next time!

📍 Support on Patreon https://www.patreon.com/unitycodemonkey
🤖 Join the Community Discord https://discord.gg/eHjUVrm
🎮 Grab the Game Bundle at https://unitycodemonkey.com/gameBundle.php
📝 Get the Code Monkey Utilities at https://unitycodemonkey.com/utils.php

#unitytutorial #unity3d #unity2d #unity​ #gamedev​ #indiegame​ #gamedevelopment #madewithunity​ #indiedev​

--------------------------------------------------------------------

Hello and Welcome!
I'm your Code Monkey and here you will learn everything about Game Development in Unity using C#.

I've been developing games for several years with 8 published games on Steam and now I'm 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.

You can see my games at www.endlessloopstudios.com

--------------------------------------------------------------------
- Other great Unity channels:
Brackeys - https://www.youtube.com/user/Brackeys
Dani - https://www.youtube.com/channel/UCIabPXjvT5BVTxRDPCBBOOQ
Jabrils - https://www.youtube.com/channel/UCQALLeQPoZdZC4JNUboVEUg
BlackthornProd - https://www.youtube.com/channel/UC9Z1XWw1kmnvOOFsj6Bzy2g
Sykoo - https://www.youtube.com/user/SykooTV
Jason Weimann - https://www.youtube.com/channel/UCX_b3NNQN5bzExm-22-NVVg
Jonas Tyroller - https://www.youtube.com/channel/UC_p_9arduPuxM8DHTGIuSOg
--------------------------------------------------------------------

- Website: https://unitycodemonkey.com/
- Twitter: https://twitter.com/UnityCodeMonkey
- Steam: https://store.steampowered.com/developer/EndlessLoopStudios







Tags:
unity mouse position to world 3d
unity mouse position
mouse raycast unity
unity cursor position
unity click position
code monkey
physics raycast
unity raycast
unity tutorial
unity game tutorial
unity tutorial for beginners
unity 2d tutorial
unity 3d
unity
game development
game dev
game development unity
unity 2d
unity 3d tutorial
programming
coding
c#
code
software development
learn to code
learn programming
unity tutorials
how to make a game