- Home /
how to disable specific axis in input manager thru the script
Hello everyone! how to disable specific axis in input manager thru the script (please C# ). Trying to disable some movement on the character in the specific state.
Comment
Why would you disable the input axis? Just stop reading from it and using its value while in the specific state.
Answer by bubzy · Nov 10, 2014 at 10:49 PM
something like this may work for you, just enable/disable the booleans
bool horizontalEnable = true;
bool verticalEnable = true;
float horizontalMove;
float verticalMove;
float moveSpeed = 0.1f;
void Update()
{
if(horizontalEnable)
{
horizontalMove = Input.GetAxis("Horizontal") * moveSpeed;
}
if(verticalEnable)
{
verticalMove = Input.GetAxis("Vertical") * moveSpeed;
}
transform.position += new Vector3(horizontalMove,verticalMove,0);
verticalMove = 0;
horizontalMove = 0;
}
Little bit tweaking of this code, and I got what i want!
Thanks a lot bubzy!!!