Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DarlesLSF |
Hello, I’m creating a topdown game and I want to use a Jump state, but idk how to do it in code. Atm I have this:
Simple right-left movement
mover = Vector2.ZERO
if Input.is_action_pressed("direita"): #right
mover.x += 1
if Input.is_action_pressed("esquerda"): #left
mover.x -= 1
mover = mover.normalized() * speed
if Input.is_action_just_pressed("pular"): #jump button
_pular()
And my jump function:
set_collision_mask_bit(2,false)
mover.y = mover.y - 10
set_collision_mask_bit(2,true)
And my _physics_process:
movimentar()
mover = move_and_slide(mover)
I tried too using an AnimationPlayer, but cant set the position.y to the actual position in the game.
What I want its the player moving like 10-15 pixels up and then back to the original position.