Comments and answers for "New Input System How to get Left Stick Axis"
http://answers.unity.com/questions/1859009/new-input-system-how-to-get-left-stick-axis.html
The latest comments and answers for the question "New Input System How to get Left Stick Axis"Comment by dogukanerdem000 on dogukanerdem000's answer
http://answers.unity.com/comments/1859059/view.html
It works! Thank you so so much, I've been trying solve this and now it works like a charm. Here is the code I am using if anyone else needs it;
Gamepad gamepad = Gamepad.current;
if (gamepad != null)
{
Vector2 stickL = gamepad.leftStick.ReadValue();
//stickL.x will be -1.0..1.0 (for full left to full right)
//stickL.y will be -1.0..1.0 (for full down to full up)
if (stickL.x < 0 && !freezePlayer)
{
theRB.velocity = new Vector2(moveSpeed * stickL.x, theRB.velocity.y);
}
else if(stickL.x > 0 && !freezePlayer)
{
theRB.velocity = new Vector2(moveSpeed * stickL.x, theRB.velocity.y);
}
else if (!pushCheck)
{
theRB.velocity = new Vector2(0, theRB.velocity.y);
}
if(stickL.x > 0 && !m_FacingRight && !freezePlayer)
{
Flip();
}
if(stickL.x < 0 && m_FacingRight && !freezePlayer)
{
Flip();
}
}Sat, 04 Sep 2021 13:32:43 GMTdogukanerdem000Answer by rh_galaxy
http://answers.unity.com/answers/1859048/view.html
Here is a try.
Code to put in Update() or FixedUpdate()
Gamepad gamepad = Gamepad.current;
if (gamepad != null)
{
Vector2 stickL = gamepad.leftStick.ReadValue();
//stickL.x will be -1.0..1.0 (for full left to full right)
//stickL.y will be -1.0..1.0 (for full down to full up)
}Sat, 04 Sep 2021 12:24:58 GMTrh_galaxy