In this Unity game development tutorial we're going to look at how we can select an object in the 3D world with the mouse by using Raycast.
If you prefer written instructions you can find a link to the text version here - https://www.ketra-games.com/2020/11/u...
In this tutorial you'll learn how to create a Ray from the Camera to the position of the mouse cursor using the Camera.ScreenPointToRay method. You'll then learn how to cast this Ray using the Physics.Raycast method to determine which game object is under the mouse cursor. Finally, you'll use this information to fire a projectile at the selected target.
00:00 - Introduction
00:35 - Changing the colour of the game object when the mouse cursor is over it
02:18 - Using Raycast to determine which game object the mouse cursor is pointing at
04:29 - Firing the ball at the selected target by applying a force to a Rigidbody
05:26 - Testing our scene
Watch video Selecting Objects in the 3D World with the Mouse Using Raycast (Unity Tutorial) online, duration hours minute second in high quality that is uploaded to the channel Ketra Games 27 November 2020. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 37,189 times and liked it 725 visitors.