@@ -51,7 +51,9 @@ func _physics_process(_delta):
5151 var is_jump_interrupted = Input .is_action_just_released ("jump" + action_suffix ) and _velocity .y < 0.0
5252 _velocity = calculate_move_velocity (_velocity , direction , speed , is_jump_interrupted )
5353
54- var snap_vector = Vector2 .DOWN * FLOOR_DETECT_DISTANCE if direction .y == 0.0 else Vector2 .ZERO
54+ var snap_vector = Vector2 .ZERO
55+ if direction .y == 0.0 :
56+ snap_vector = Vector2 .DOWN * FLOOR_DETECT_DISTANCE
5557 var is_on_platform = platform_detector .is_colliding ()
5658 _velocity = move_and_slide_with_snap (
5759 _velocity , snap_vector , FLOOR_NORMAL , not is_on_platform , 4 , 0.9 , false
@@ -60,7 +62,10 @@ func _physics_process(_delta):
6062 # When the character’s direction changes, we want to to scale the Sprite accordingly to flip it.
6163 # This will make Robi face left or right depending on the direction you move.
6264 if direction .x != 0 :
63- sprite .scale .x = 1 if direction .x > 0 else - 1
65+ if direction .x > 0 :
66+ sprite .scale .x = 1
67+ else :
68+ sprite .scale .x = - 1
6469
6570 # We use the sprite's scale to store Robi’s look direction which allows us to shoot
6671 # bullets forward.
@@ -106,9 +111,15 @@ func calculate_move_velocity(
106111func get_new_animation (is_shooting = false ):
107112 var animation_new = ""
108113 if is_on_floor ():
109- animation_new = "run" if abs (_velocity .x ) > 0.1 else "idle"
114+ if abs (_velocity .x ) > 0.1 :
115+ animation_new = "run"
116+ else :
117+ animation_new = "idle"
110118 else :
111- animation_new = "falling" if _velocity .y > 0 else "jumping"
119+ if _velocity .y > 0 :
120+ animation_new = "falling"
121+ else :
122+ animation_new = "jumping"
112123 if is_shooting :
113124 animation_new += "_weapon"
114125 return animation_new
0 commit comments