diff --git a/src/playerD/Player.tscn b/src/playerD/Player.tscn index 07457f8..e9f2884 100644 --- a/src/playerD/Player.tscn +++ b/src/playerD/Player.tscn @@ -570,7 +570,7 @@ interactable_node = NodePath("../Interactable_Receiver") [node name="idle" parent="movement_state_machine" index="0"] script = ExtResource( 4 ) -move_speed = 0.0 +move_speed = 1.0 animation_sequence = [ "idle" ] jump_node = NodePath("../jump") attack_node = NodePath("../attack") diff --git a/src/state_animated_actor.gd b/src/state_animated_actor.gd index a0e5983..6ff19be 100644 --- a/src/state_animated_actor.gd +++ b/src/state_animated_actor.gd @@ -23,7 +23,7 @@ export var move_speed_modifier: float = 0 export var move_modifier_move_acceleration: float = 0 export var jerk_factor: float = 0 -var adjusted_move_speed: float +#var adjusted_move_speed: float var jerk: float var physics_modifier :StateModifier @@ -168,7 +168,7 @@ func enter() -> void: update_animation() # Reset movespeed counters - adjusted_move_speed = move_speed_modifier + move_component.momentum.x = move_speed_modifier jerk = 0 return @@ -283,19 +283,36 @@ func move_actor_as_desired(delta: float, x_direction: float = 0): # else: # UiManager.debug_text = '' + # We have no speed but left over momentum. +# if _move_speed == 0 and move_component.momentum.x != 0.0: +# # W +# pass + + # 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 jerk += _jerk_factor * delta - adjusted_move_speed += _move_modifier_move_acceleration * delta +# adjusted_move_speed += _move_modifier_move_acceleration * delta + move_component.acceleration.x = _move_modifier_move_acceleration + _move_acceleration + move_component.momentum.x += _move_modifier_move_acceleration * delta #Another crappy normalization hack - if adjusted_move_speed > _move_speed_modifier and _move_speed_modifier > 0: - adjusted_move_speed = _move_speed_modifier - elif adjusted_move_speed < _move_speed_modifier and _move_speed_modifier < 0: - adjusted_move_speed = _move_speed_modifier + if move_component.momentum.x > _move_speed_modifier and _move_speed_modifier > 0: + move_component.momentum.x = _move_speed_modifier + #move_component.acceleration.x = 0 + elif move_component.momentum.x < _move_speed_modifier and _move_speed_modifier < 0: + move_component.momentum.x = _move_speed_modifier + #move_component.acceleration.x = 0 + + # Crappy momentum shutdown routines when the modifier doesn't apply if _move_speed_modifier == 0: - adjusted_move_speed = 0 + if move_component.momentum.x > 0 and move_component.acceleration.x > 0: + move_component.momentum.x = 0 + move_component.acceleration.x = 0 + elif move_component.momentum.x < 0 and move_component.acceleration.x < 0: + move_component.momentum.x = 0 + move_component.acceleration.x = 0 - var new_move_speed = (_move_speed + _move_speed_modifier ) + (_move_acceleration * delta) + adjusted_move_speed + 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. @@ -308,8 +325,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(adjusted_move_speed)) + "," + 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) @@ -323,23 +340,3 @@ func move_actor_as_desired(delta: float, x_direction: float = 0): 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)) - -# var new_speed = move_speed * speed_multiplier -# if speed_multiplier > 1.0: -# speed_multiplier -= delta * speed_multiplier -# #speed_decay_rate += delta * speed_decay_rate -# -# elif speed_multiplier < 1.0: -# speed_multiplier += delta * speed_multiplier -# #speed_decay_rate += delta * speed_decay_rate -# -# # Deadzone -# if speed_multiplier < 1.1 and speed_multiplier > 0.9: -# speed_multiplier = 1.0 -## if (new_speed > move_speed): -## print("Go Faster Booooy! ", move_speed) -# move_component.velocity.y += gravity * delta -# #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1)) -# move_component.velocity.x = move_component.desired_movement_vector.x * new_speed -# move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1)) -