Game Development Reference
In-Depth Information
Step 24. Select the ball prefab in the Project. At the very top of the
Inspector click on Tag. Select Add Tag from the pop-up menu. The
Inspector will change to a different view. Select the triangle next to
Tags at the very top of the Inspector and type ball into Element 0.
Reselect the ball prefab in the Project, click on Tag again, and find the
newly added ball tag in the pop-up menu. Select it. This process is
illustrated in Figure 4.7 .
Fig 4.7 Adding a new tag.
Unity Hands On
Matching and Sorting—Continued
Step 1. Create a new JavaScript file called clickndrag , add the code
in Listing 4.6 , and attach it to the ball prefab.
Listing 4.6 Script Allowing Mouse Selection and Dragging of
Game Object
private var focusObj: GameObject = null;
private var lastMousePosition: Vector3;
private var deltaMousePosition: Vector3;
var mouseSensitivity = 40.0;
function Update ()
{
//when fire button is pressed
if( Input.GetButtonDown("Fire1"))
{
focusObj = null;
//cast a ray
var ray = Camera.main.ScreenPointToRay (Input.
mousePosition);
var hit : RaycastHit;
Search Nedrilad ::




Custom Search