Selecting a Target with the Mouse - Unity Game Development Tutorial
In this Unity game development tutorial we're going to look at how we can select a target in the 3D world using the mouse. You can either watch the video version below or continue reading for written instructions. We're going to start with the scene we created in our ' Colliding with Obstacles ' tutorial. We've got a ball and a stack of boxes that all have a Rigidbody component attached so that they react to forces and collisions. We're going to add the ability to select a target with the mouse and then fire the ball at the selected target when the left mouse button is clicked. The first thing we're going to do is make the cardboard box change colour when the mouse cursor is over it, so the player knows which box they are targeting. To do this, we'll go to the Project panel and navigate to Assets->CrowArt PBR Cardboard Box->Prefabs, and we'll select the 'CarboardBox_1' box prefab. We'll add a script to the prefab by clickin