-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Unity 4.x Game Development by Example: Beginner's Guide
By :

Change your Debug.Log()
call so that it looks like this:
Debug.Log( (Input.mousePosition.x -Screen.width/2) / (Screen.width/2) );
Ack! So many brackets! We use those brackets because we want the division and subtraction stuff to happen in the right sequence. You may remember order of operations rules from algebra class. BEDMAS: evaluate the Brackets first, then the Exponents, then Division, Multiplication, Addition, and finally Subtraction.
To wrap your brain around it, here's what we're doing, in pseudocode:
(first thing)/(second thing)
We're dividing something by something else. The first thing is the -640 to 640 number range that we cooked up. The second thing is Screen.width/2
(the screen's midpoint). We wrap all of that in a tasty Debug.Log()
shell:
Debug.Log((first thing)/(second thing));
Pseudocode is fake code that will not work if you type it into a Script. We're just using it to better understand the real code that we're writing...
Change the font size
Change margin width
Change background colour