jump and run working
This commit is contained in:
1 parent
c813ce8f0c
commit
87ff9b7f7f
29 files changed
+337
-28
No files matched your search
@@ -10,6 +10,7 @@ extends CharacterBody2D
|
||||
@onready var left_ray = $LeftRay
|
||||
@onready var marker_right = $MarkerRight
|
||||
@onready var marker_left = $MarkerLeft
|
||||
@onready var animated_sprite = $AnimatedSprite2D
|
||||
|
||||
var faceLeft = false
|
||||
var pushLeftEnabled = false
|
||||
@@ -57,8 +58,16 @@ func _physics_process(delta):
|
||||
|
||||
if direction:
|
||||
velocity.x = direction * SPEED
|
||||
animated_sprite.flip_h = true if direction <0 else false
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
if is_on_floor():
|
||||
if direction == 0:
|
||||
animated_sprite.play("idle")
|
||||
else:
|
||||
animated_sprite.play("run")
|
||||
else:
|
||||
animated_sprite.play("jump")
|
||||
|
||||
move_and_slide()
|
||||
if right_ray.is_colliding():
|
||||
|
||||
Reference in new issue
Block a user