- Home /
Having an issue with Input.ResetInputAxes
I have a function that disables the movement of the player for the duration of an animation.
IEnumerator AnimationRooting(float seconds) //Locks player in a root state after attacking
{
pStats.canMove = false;
rigidbd.velocity = new Vector2(0, 0); //Sets the player in a root state
yield return new WaitForSeconds(seconds);
Input.ResetInputAxes(); //Disables the player from instantly accelerating to a 100%
pStats.canMove = true;
}
If I comment Input.ResetInputAxes the players stops temporarily before he accelerates at the same speed as before. (Assuming the person has held down the Input keys the whole time)
When I have that line of code the acceleration is smooth, however, I found a bug.
Assuming I've held down both down and right arrow - the player moves diagonally until I press the attack button and the function is called. The player is still for x seconds and then accelerates in only one axis. The other one is completely locked until I let go of the button and press it down again.
Here is a representation of what I mean:
https://gyazo.com/d56743613942a5f897531d8ea62c0169
If you can't open it comment on my question and I will try to link it to you.
Here is my movement code in case you want to test it yourself:
private void FixedUpdate()
{
if (pStats.canMove == true)
{
Vector2 movePos = Vector2.right * Input.GetAxis("Horizontal") + Vector2.up * Input.GetAxis("Vertical");
rigidbd.velocity = movePos * Time.deltaTime * 50 * moveSpeed;
}
}
Answer by xxmariofer · Feb 21, 2019 at 08:31 PM
hello, thats a bug and should be submitted to unity directly. it is an extrange bug. when submmitting the bug tell them that the input that is not getting update after the reset is the first one of the 2 you push (for example if you press the horizontal axis first will not update after the reset) and if you push both buttons and then you play the game both work fine.
type in the windows explorer report a problem with unity and there should be a shortcut, if not there is an exe in the same folder with that name next to the unity.exe
Your answer
Follow this Question
Related Questions
Smooth movement help? 1 Answer
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
how to move an object in 2D sense its position? 0 Answers
Gradual Speed Increase with Variable Input 0 Answers
How to Move a Cube 3 Answers