From d1d7e24936ad7e22eaf4e190683361d04b78e9a4 Mon Sep 17 00:00:00 2001 From: Dustin Date: Tue, 27 May 2025 21:52:42 -0700 Subject: [PATCH] Movement based only on input for static movement. No acceleration then only input. --- lib/classes/movement_state_receiver.gd | 1 + .../playerE/PlayerE-Movement_StateReceiver.gd | 1 - src/classes/velocity_controller.gd | 46 ++++++++++++------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/lib/classes/movement_state_receiver.gd b/lib/classes/movement_state_receiver.gd index 53552e6..e5d0188 100644 --- a/lib/classes/movement_state_receiver.gd +++ b/lib/classes/movement_state_receiver.gd @@ -69,6 +69,7 @@ func process_physics(delta): # more likely needed for Players func process_physics_input(delta): physics_delta = delta + desired_movement_vector = Vector2(0,0) if has_method('_state_process_physics_input_' + current_state.name): call('_state_process_physics_input_' + current_state.name) diff --git a/src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd b/src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd index b996349..58347f3 100644 --- a/src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd +++ b/src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd @@ -119,7 +119,6 @@ func process_physics_input(delta): # call the parent, Which would call the individuals .process_physics_input(delta) # then process movement controls - physics_delta = delta get_movement_direction() wants_jump() wants_crouch() diff --git a/src/classes/velocity_controller.gd b/src/classes/velocity_controller.gd index 044820b..db88487 100644 --- a/src/classes/velocity_controller.gd +++ b/src/classes/velocity_controller.gd @@ -47,8 +47,24 @@ func calculate_velocity(_delta :float, # no desired movement we'll continue to travel in that direction. ## ## If an override has been passed (we're ignoring input direction + ##TODO: Should preserve initia apply here var move_direction = Vector2.ZERO - move_direction = resolve_move_direction(calc_inertia, _movement_direction) + move_direction = resolve_move_direction(calc_inertia, _movement_direction) + + ## Acceleration is always postive because we use the current inertia + ## placement to the movement range to determine direction of movement. + if sign(move_direction.x) != 0: + #calc_acceleration.x = abs(movement_parameters.get_acceleration(0).x) + calc_acceleration.x = movement_parameters.get_acceleration().x + assert(calc_acceleration.x >= 0, "Negative X Acceleration shouln't happen") + if is_zero_approx(calc_acceleration.x): + move_direction.x = _movement_direction.x + + if sign(move_direction.y) != 0: + calc_acceleration.y = movement_parameters.get_acceleration().y + assert(calc_acceleration.y >= 0, "Negative Y Acceleration shouln't happen") + if is_zero_approx(calc_acceleration.y): + move_direction.y = _movement_direction.y ## Inertia only applies if there is a difference between the @@ -89,17 +105,6 @@ func calculate_velocity(_delta :float, var h_range_placement = placement_to_speed_range(calc_velocity.x, h_speed) var v_range_placement = placement_to_speed_range(calc_velocity.y, v_speed) - ## Acceleration is always postive because we use the current inertia - ## placement to the movement range to determine direction of movement. - if sign(move_direction.x) != 0: - #calc_acceleration.x = abs(movement_parameters.get_acceleration(0).x) - calc_acceleration.x = movement_parameters.get_acceleration().x - assert(calc_acceleration.x >= 0, "Negative X Acceleration shouln't happen") - - if sign(move_direction.y) != 0: - calc_acceleration.y = movement_parameters.get_acceleration().y - assert(calc_acceleration.y >= 0, "Negative Y Acceleration shouln't happen") - ## We don't want to be able to scoot our impulse speed to cheat the movement # Any non zero speed that goes opposite to our inertial direction # should only be allowed once. @@ -152,8 +157,15 @@ func calculate_velocity(_delta :float, (calc_acceleration.x * _delta) ) else: - if is_zero_approx(move_direction.x) == false: - calc_inertia.x = h_speed.x + ## Using static move directions insteead of inertial move directions +# if is_zero_approx(_movement_direction.x) == false: +# calc_inertia.x = h_speed.x +# else: +# calc_inertia.x = 0.0 + calc_inertia.x = h_speed.x + if debug and movement_parameters.debug_name == 'jump': + var foo = 2+2 + if is_zero_approx(calc_acceleration.y) == false: calc_inertia.y = resolve_inertia( @@ -163,8 +175,10 @@ func calculate_velocity(_delta :float, (calc_acceleration.y * _delta) ) else: - if is_zero_approx(move_direction.y) == false: - calc_inertia.y = v_speed.x + ## Using static move directions insteead of inertial move directions +# if is_zero_approx(_movement_direction.y) == false: +# calc_inertia.y = v_speed.x + calc_inertia.y = v_speed.x ## Track or last speed for in range impulses # _h_impulse_speed_tracking = h_speed