diff --git a/src/playerD/states/idle.gd b/src/playerD/states/idle.gd index 2dcc654..d9345dd 100644 --- a/src/playerD/states/idle.gd +++ b/src/playerD/states/idle.gd @@ -38,9 +38,9 @@ func process_physics(delta: float) -> State: if move_component.wants_shoot(): return attack_state - move_actor_as_desired(delta, parent.transform.x.x * -1) + move_actor_as_desired(delta) - if move_component.desired_movement_vector.x != 0: + if move_component.desired_movement_vector.x != 0 and move_component.velocity.x != 0: return move_state if !parent.is_on_floor(): diff --git a/src/state_animated_actor.gd b/src/state_animated_actor.gd index 2b8992c..40ae459 100644 --- a/src/state_animated_actor.gd +++ b/src/state_animated_actor.gd @@ -260,14 +260,16 @@ func process_physics(_delta: float) -> State: # if animations.frames.get_animation_loop(animations.animation) == false: # animation_index += 1 -func move_actor_as_desired(delta: float, x_direction: float = 0): - +func move_actor_as_desired(delta: float, x_impulse_direction: float = 0): + var _move_acceleration:float = 0.0 var _move_speed = move_speed var _move_speed_modifier = move_speed_modifier - #var _move_modifier_move_acceleration = move_modifier_move_acceleration - if move_modifier_move_acceleration != 0: - move_component.acceleration.x = move_modifier_move_acceleration - var _move_acceleration = move_acceleration +# var _move_modifier_move_acceleration = move_modifier_move_acceleration +# var _move_acceleration = move_acceleration + + _move_acceleration += move_modifier_move_acceleration + _move_acceleration += move_acceleration + var _jerk_factor = jerk_factor var _gravity = gravity @@ -280,11 +282,18 @@ func move_actor_as_desired(delta: float, x_direction: float = 0): _move_speed = mod_props.move_speed _move_speed_modifier += mod_props.move_speed_modifier _move_acceleration += mod_props.move_acceleration - if move_component.acceleration.x != (mod_props.move_modifier_move_acceleration + move_modifier_move_acceleration): - move_component.acceleration.x = mod_props.move_modifier_move_acceleration + move_modifier_move_acceleration +# _move_modifier_move_acceleration += mod_props.move_modifier_move_acceleration + _move_acceleration += mod_props.move_modifier_move_acceleration _jerk_factor += mod_props.jerk_factor # else: # UiManager.debug_text = '' + + if x_impulse_direction == 0: + x_impulse_direction = 1 + + # Help to preserve momentum I guess + if _move_acceleration != 0: + move_component.acceleration.x = _move_acceleration #* x_impulse_direction # Assuming adjusted_move_speed is set to the mood speed modifier on state entry # Move speed is the base speed plus the modifier minus the decay adjusted for time @@ -307,7 +316,9 @@ func move_actor_as_desired(delta: float, x_direction: float = 0): move_component.momentum.x = 0 move_component.acceleration.x = 0 - var new_move_speed = (_move_speed + _move_speed_modifier ) + (_move_acceleration * delta) + move_component.momentum.x + jerk + var new_move_speed = (_move_speed + _move_speed_modifier ) + move_component.momentum.x + jerk + +# var new_move_speed = (_move_speed + _move_speed_modifier ) + (_move_acceleration * delta) + move_component.momentum.x + jerk # A really crappy normalization to prevent modifying past the base move speed. @@ -320,8 +331,8 @@ func move_actor_as_desired(delta: float, x_direction: float = 0): new_move_speed = _move_speed #adjusted_move_speed = 0 else: - if new_move_speed != move_speed: - UiManager.debug_text = str(round(move_component.momentum.x)) + "," + str(round(new_move_speed)) + "," + str(round(jerk)) + #if new_move_speed != move_speed: + UiManager.debug_text = "S:" + str(round(new_move_speed)) + ",M" + str(round(move_component.momentum.x)) + ",A" + str(round(move_component.acceleration.x)) # str(round(jerk)) #print(adjusted_move_speed, ",", new_move_speed, ",", jerk) #print(new_move_speed, " ", adjusted_move_speed) @@ -329,10 +340,7 @@ func move_actor_as_desired(delta: float, x_direction: float = 0): move_component.velocity.y += _gravity * delta #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1)) #print(speed_multiplier) - if (x_direction != 0): - move_component.velocity.x = x_direction * new_move_speed - else: - move_component.velocity.x = move_component.desired_movement_vector.x * new_move_speed + move_component.velocity.x = move_component.desired_movement_vector.x * new_move_speed move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))