Here is an example script showing 2 ways to check for changes in the mouse while the RMB is pressed.
The first basically reads the Input Manager value for Input.GetAxis( “Mouse X” )
The second calculates the changes in mouse position by remembering where it was last frame, then subtracting that from the current position.
Create a new scene, and attach this script to an empty gameObject. Hit Play, hold the RMB and move the mouse, check the output in the console. This is showing Input.GetAxis( “Mouse X” ). Now while still playing, change the boolean to false. Hold RMB and move mouse, now the console is displaying the calculations for the delta method.
Input.mousePosition gives screen coordinates, I have no clue what GetAxis returns, but that explains the difference in the values for the same movement. EDIT : (with help from fafase) the Unity Scripting Reference states If the axis is setup to be delta mouse movement, the mouse delta is multiplied by the axis sensitivity and the range is not -1…1.
You can fix the values from Input.mousePosition to a normalized value (which I recommend) by dividing the delta x and y by Screen.width and height. I have included this i the function, that is why there are 2 debugs : before and after normalization, normalize usually means a value between 0 and 1 (0 nothing, 1 maximum possible).
SO first calculate a value based on changes in the mouse using one of the methods I have shown, then use that value in the modification of your camera position =]
hee hee, thanks dude =] What I was referring to explicitly was how is this value calculated? If you move the mouse quick enough with the above script, axisDelta x and y returns values above 1, therefore are not normalized. I assumed it would say "ok, i can move a maximum of Screen.width, the mouse moved x% of that amount, so I shall return x/Screen.width". Unless the mouse is moved for a distance larger than scrolling the mouse cursor on the screen allows that's why it can return > 1
lol, never used it for mouse myself. If all else fails, read the API hey ! Here is the information for future readers (answer also updated) : If the axis is setup to be delta mouse movement, the mouse delta is multiplied by the axis sensitivity and the range is not -1...1.http://docs.unity3d.com/Documentation/ScriptReference/Input.GetAxis.html "Look mom, I learned something today !"
No worries, but .... Please don't post comments as answers. Post comments by clicking the [add new comment] button, a window then open for you to type in. Answer fields are for answers only, as this is a knowledge base. Here at Unity Answers, Answer means Solution, not Response.
well give axis gives -1 || 0 || 1 not anything else if (Input.GetMouseButtonUp(1)) { MoveMe += (Input.GetAxis("Mouse Y")); transform.Translate (0,0, MoveMe * Time.deltaTime); } hope helps
– sdgd