September 2010
Beginner
384 pages
8h 49m
English
This code's not going to work. Our paddle moves only to the right, along the positive X-axis, because we're working only with positive numbers. We need some negative numbers in there so that the paddle will move to the left at some point. But, at what point?
Hmm… what if we take half of the screen's width and subtract it from Input.mousePosition.x? What does that do for us?
A quick trip to the Unity Language Reference tells us how to find the width of the screen in pixels. Let's divide that number by two and subtract it from the mouse position.
Change the Debug.Log() function call to look like this:
Debug.Log(Input.mousePosition.x - Screen.width/2);
Save and test. Watch the bottom of the screen for the result.
Read now
Unlock full access