HI
float forwardPressed = Keyboard.current.wKey.ReadValue();
float backwardPressed = Keyboard.current.sKey.ReadValue();
float leftPressed = Keyboard.current.aKey.ReadValue();
float rightPressed = Keyboard.current.dKey.ReadValue();
//process animations
if(motor.isGrounded && moveDirection == Vector3.zero)
{
velocityZ = 0;
velocityX = 0;
}
if(motor.isGrounded && forwardPressed > 0)
{
velocityZ += Time.deltaTime * acceleration;
}
if(motor.isGrounded && moveDirection.z < 0)
{
velocityZ -= Time.deltaTime * acceleration;
}
if(motor.isGrounded && moveDirection.x > 0)
{
velocityX += Time.deltaTime * acceleration;
}
if(motor.isGrounded && moveDirection.x < 0 && velocityX > -1.0f)
{
velocityX -= Time.deltaTime * acceleration;
}
animator.SetFloat("VelocityZ", velocityZ);
animator.SetFloat("VelocityX", velocityX);
I’m trying to use the new Input System and trying to check if forward is pressed. If forward is pressed, then play forward animation.
My question is how to get “forwardPressed”.
Thx in advance!