Hello. I am trying to map my mouse X and Y to the arrow keys, but when I go into the input manager and add keys to the negative and positive positions of mouseX and mouseY, nothing happens in game. Is there a way to do this with scripting or fix the problem of the inputs not working?
1 Answer
1The correct way to approach this problem is not to map keys as mouse axes, but rather have your code check for one, the other, or both input types.
void Update()
{
if (Input.GetButton("Left Button") || Input.GetAxis("Mouse X") < 0)
{
// Do Left Action or set leftButtonDown flag
}
if (Input.GetButton("Right Button") || Input.GetAxis("Mouse X") > 0)
{
// Do Right Action or set rightButtonDown flag
}
}