Hello everyone! So I'm trying to get four-way movement with a 3D player character working with both keyboard and controller.
The player's Animator is using a 1D blend (0 = idle, 0.5 & -0.5 = walk,).
The issue is that for some reason my Walk right (0.5) and Walk Left(-0.5) animations will play when the Horizontal Axis on the keyboard or controller are used. BUT The walking animation doesn't play when my character is moving forward or back. I'm sure I'm making some sort of mistake I just don't know what.
Side note: My character continues moving(sliding) after I've stopped walking. This only happens when using the keyboard and not with the controller. I'm not sure if this is related to the above problem or not.
//Gets Attached Players Animator
playerAnimator = playerObject.GetComponent();
//Forward/Left-Right Param
var inputy = playerAnimator.GetFloat("InputY");
//Movment Controller
if (Input.GetAxis("Vertical") >0)
{
transform.position += Vector3.forward * Time.deltaTime * moveSpeed;
playerAnimator.SetFloat("InputY", 0.5f);
}
if (Input.GetAxis("Vertical") < 0)
{
transform.position += Vector3.back * Time.deltaTime * moveSpeed;
playerAnimator.SetFloat("InputY", -0.5f);
}
if (Input.GetAxis("Vertical") == 0)
{
transform.position += Vector3.zero * Time.deltaTime * moveSpeed;
playerAnimator.SetFloat("InputY", 0);
}
if (Input.GetAxis("Horizontal") > 0)
{
transform.position += Vector3.right * Time.deltaTime * moveSpeed;
playerAnimator.SetFloat("InputY", 0.5f);
}
if (Input.GetAxis("Horizontal") < 0)
{
transform.position += Vector3.left * Time.deltaTime * moveSpeed;
playerAnimator.SetFloat("InputY", -0.5f);
}
if (Input.GetAxis("Horizontal") == 0)
{
transform.position += Vector3.zero * Time.deltaTime * moveSpeed;
playerAnimator.SetFloat("InputY", 0);
}
↧