September 2010
Beginner
384 pages
8h 49m
English
Debug.Log() function call):function Update () {
var halfW : float = Screen.width/2;
transform.position.x = (Input.mousePosition.x -halfW)/halfW;
}
That code looks a lot cleaner. Not only is it easier to read, but we've knocked out some of those confusing brackets in the second line.
We've used the special var keyword to declare our variable (bucket). I chose the name halfW, which is short for "half width" half the width of the screen. You can choose any name you like for a variable as long as it isn't a reserved Unity keyword, and it doesn't break any of the naming rules that ...
Read now
Unlock full access