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
Смотрите видео Selecting Objects in the 3D World with the Mouse Using Raycast (Unity Tutorial) онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Ketra Games 27 Ноябрь 2020. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 37,189 раз и оно понравилось 725 посетителям.