Input.GetAxis("Mouse X") returns 0 no matter what.
Hello I can't work out if this is a bug or not I am developing a game for the vive and for some reason the input from the mouse is not working. My code is Debug.log(Input.GetAxis("Mouse X")) in the Update function. The output is 0 no matter how much I wiggle the mouse.
Is there another way to access the mouse input rather than using the input menu?
Answer by Zodiarc · Sep 09, 2016 at 11:49 AM
Maybe there is a screwup in the input mapping. https://docs.unity3d.com/Manual/class-InputManager.html
Answer by Inbasagar · Sep 09, 2016 at 10:59 AM
Try Input.mousePosition.x
EDIT:-
Vector2 pos;
public float Sensitivity = 0.2f;
void Update(){
Rotatecam();
}
void Rotatecam(){
if (Input.GetMouseButtonDown(0))
{
pos = Input.mousePosition;
}
if (Input.GetMouseButton(0) || Application.isMobilePlatform)
{
transform.localEulerAngles += new Vector3((Input.mousePosition.y - pos.y) * Sensitivity, (-Input.mousePosition.x + pos.x) * Sensitivity, 0);
pos = Input.mousePosition;
}
}
I guess this'll work ;)
The problem is I want the mouse movement not it's position so I can rotate a camera.
Your answer
Follow this Question
Related Questions
GetAxis mouse on windows return 0 1 Answer
Event on mouse up 2 Answers
Confine mouse to a plane 1 Answer
Mouse Click Plays an Animation 1 Answer