i am using god 3.5 windows 10
2D platformer game.
here is my code
enum States {AIR = 1, FLOOR, LADDER, WALL}
var state = States.AIR
var velocity = Vector2(0,0)
var is_jumping = true
const SPEED = 210
const GRAVITY = 35
const JUMPFORCE = -1100
func physicsprocess(delta):
match state:
States.AIR:
if isonfloor():
state = States.FLOOR
continue
$Sprite.play("Air")
if Input.isactionpressed("Right"):
velocity.x = SPEED
$Sprite.fliph = false
elif Input.isactionpressed("Left"):
velocity.x = SPEED
$Sprite.fliph = true
else:
velocity.x = lerp(velocity.x,0,0.2)
moveandfall()
States.FLOOR:
if not isonfloor():
state = States.AIR
if Input.isactionpressed("Right"):
velocity.x = SPEED
$Sprite.play("Walk")
$Sprite.fliph = false
elif Input.isactionpressed("Left"):
velocity.x = -SPEED
$Sprite.play("Walk")
$Sprite.fliph = true
else:
$Sprite.play("Idle")
velocity.x = lerp(velocity.x, 0,0.2)
if Input.is_action_just_pressed("Jump"):
velocity.y = JUMPFORCE
$SoundJump.play()
state = States.AIR
move_and_fall()
func moveandfall():
velocity.y = velocity.y + GRAVITY
var snap = Vector2.DOWN * 32 if !isjumping else Vector2.ZERO
velocity = moveandslidewith_snap(velocity, snap, Vector2.UP)
when I run the level I can walk in both directions and jump straight up
and walk to the right and jump at the same time
but when I try to walk to the left and jump at the same time it jumps me back to the rigt