- Home /
Key Mapping
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?
Comment
Answer by iwaldrop · Apr 15, 2013 at 05:39 PM
The 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
}
}
Your answer
Follow this Question
Related Questions
Two keys-Same function 1 Answer
InputManager, Gamepads, Wheels: remapping and calibrating 1 Answer
How to map input for new Samsung Gear VR controller? 3 Answers
Redefining input within game 1 Answer
Rotate an object with angle limit 1 Answer