hello
I am trying to make my character jump it works fine, but if I start moving in mid-jump the character stops jumping and starts moving left and right if I stop the character continues jumping, same problem when the character is falling
this is a video showing the problem
and here is my code :
private void Awake()
{
animator = GetComponent<Animator>();
player_RB = GetComponent<Rigidbody2D>();
player_controle = new PlayerInput();
player_controle.Player.Enable();
player_controle.Player.Run.performed += Run_performed;
player_controle.Player.Jump.performed += Jump_performed;
}
private void FixedUpdate()
{
float player_speed = 10f;
Vector2 inputVector = player_controle.Player.Move.ReadValue<Vector2>();
if (inputVector.x != 0 )
{
player_RB.MovePosition(player_RB.position + inputVector * player_speed * Time.deltaTime);
change_Animation(animation_state.Run.ToString());
idle_animation();
}
else if (player_state == state.Idle.ToString())
{
change_Animation(animation_state.Idle.ToString());
}
}
private void Jump_performed(InputAction.CallbackContext callback)
{
if (callback.performed)
{
player_RB.velocity = Vector2.up * 10f;
Debug.Log("player is jumoing ");
change_Animation(animation_state.jump.ToString());
player_state = state.jumping.ToString();
}
}