- Home /
Xbox Controller RT Button does not revert to 0 until other input is applied (some times)
Hello, I am trying to use an Xbox 1 controller to control my game via the "Input manager". I have set up the "RT" button on the controller to freeze the Y axis. It seems to work well 50% of the time but if I press the button quickly or if I hold it in, it sticks when I release it (Debug.Log confirms it is reading that the RT button is being held in). I thought that maybe the buttons were sticking so I tried the LT button and got the same thing. If I set it to Axis 5 or Button 1 I do not get the problem. I still don't think that both buttons are sticking because A)The character starts behaving normally once I press/move any other button or joystick B) it's a new controller and those buttons do not stick in the few games I have tried with it .
The attached image shows the settings in the input manager:
And here is my code:
//Code that does not effect this has been removed for readability
private void GetInputs()
{
if (PlayerControlsEnabled)
{
this.Horizontal = Input.GetAxis("Horizontal");
this.Vertical = Input.GetAxis("Vertical");
this.Jump = Input.GetAxis("Jump");
this.RT = Input.GetAxis("RT");
}
}
//Code that does not effect this has been removed for readability
//Note rb2d is a RigidBody2D
public void MovePlayer()
{
if (this.Horizontal > 0) //Move Right
{
this.transform.eulerAngles = new Vector2(0, 0);//Flip player to face the right
if(this.rb2d.velocity.magnitude <= this.MaxNormalSpeed)//Don't excede the max speed
this.rb2d.AddForce(Vector2.right * this.ForwardForce * Time.deltaTime, ForceMode2D.Impulse);
}
if(this.Horizontal < 0) // Move Left
{
this.transform.eulerAngles = new Vector2(0, 180);//Flip player to face the left
if(this.rb2d.velocity.magnitude <= this.MaxNormalSpeed) //Don't excede the max speed
this.rb2d.AddForce(-Vector2.right * this.ForwardForce * Time.deltaTime, ForceMode2D.Impulse);
}
if (this.Jump > 0) //Jump
this.rb2d.AddForce(transform.up * JumpForce *Time.deltaTime);
if(IsFlying)
{
if (this.Vertical > 0)
this.rb2d.AddForce(transform.up * this.FlyingUpwardForce * Time.deltaTime);
if (this.RT < 0) //If Right Trigger is pressed apply air breaks
{
this.rb2d.constraints = RigidbodyConstraints2D.FreezePositionY;
}
else //If Right trigger is not pressed remove the air breaks
{
this.rb2d.constraints = RigidbodyConstraints2D.None;
}
}
Your answer
Follow this Question
Related Questions
Using Trigger Keys on Xbox Controller To Zoom 2 Answers
Active input handling with input sytem 0 Answers
Is there a way to detect a change in Control Scheme with the new Input System? 1 Answer
create default and customizable inputs 0 Answers
Input Manager settings not working with XBox One controller 1 Answer