Time for action – Log the New Number
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));
Note
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...