How to convert the mouse position to world space in Unity

Опубликовано: 28 Февраль 2025
на канале: Game Dev Beginner
40,071
979

Want to know how to CODE in Unity? Get my course here: https://www.udemy.com/course/how-to-c...

Learn how to convert the mouse position on the screen to a real position in the game world in Unity

p.s. if you're using Unity's new Input System: instead of Input.mousePosition, type Mouse.current.position.ReadValue();

00:00 Intro
00:36 Get the mouse's screen position
01:50 Screen to World Point
05:30 Screen Point to Ray
09:10 Using a Layer Mask with the Ray
14:06 Plane Raycast
17:54 Outro

You'll learn how to use Screen to World Point, Screen Point to Ray and Plane Raycast, to translate a mouse's screen position to a position in your game's scene.

For more information, read the full article here: https://gamedevbeginner.com/how-to-co...

Unity icons created by Freepik: https://www.flaticon.com/free-icons/u...