Movement based only on input for static movement. No acceleration then only input.

This commit is contained in:
Dustin 2025-05-27 21:52:42 -07:00
parent a0aae4fbcb
commit d1d7e24936
3 changed files with 31 additions and 17 deletions

View File

@ -69,6 +69,7 @@ func process_physics(delta):
# more likely needed for Players # more likely needed for Players
func process_physics_input(delta): func process_physics_input(delta):
physics_delta = delta physics_delta = delta
desired_movement_vector = Vector2(0,0)
if has_method('_state_process_physics_input_' + current_state.name): if has_method('_state_process_physics_input_' + current_state.name):
call('_state_process_physics_input_' + current_state.name) call('_state_process_physics_input_' + current_state.name)

View File

@ -119,7 +119,6 @@ func process_physics_input(delta):
# call the parent, Which would call the individuals # call the parent, Which would call the individuals
.process_physics_input(delta) .process_physics_input(delta)
# then process movement controls # then process movement controls
physics_delta = delta
get_movement_direction() get_movement_direction()
wants_jump() wants_jump()
wants_crouch() wants_crouch()

View File

@ -47,9 +47,25 @@ func calculate_velocity(_delta :float,
# no desired movement we'll continue to travel in that direction. # no desired movement we'll continue to travel in that direction.
## ##
## If an override has been passed (we're ignoring input direction ## If an override has been passed (we're ignoring input direction
##TODO: Should preserve initia apply here
var move_direction = Vector2.ZERO 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 ## Inertia only applies if there is a difference between the
# base move speed and a derived move speed. This makes it so all you # base move speed and a derived move speed. This makes it so all you
@ -89,17 +105,6 @@ func calculate_velocity(_delta :float,
var h_range_placement = placement_to_speed_range(calc_velocity.x, h_speed) 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) 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 ## 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 # Any non zero speed that goes opposite to our inertial direction
# should only be allowed once. # should only be allowed once.
@ -152,8 +157,15 @@ func calculate_velocity(_delta :float,
(calc_acceleration.x * _delta) (calc_acceleration.x * _delta)
) )
else: else:
if is_zero_approx(move_direction.x) == false: ## Using static move directions insteead of inertial move directions
calc_inertia.x = h_speed.x # 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: if is_zero_approx(calc_acceleration.y) == false:
calc_inertia.y = resolve_inertia( calc_inertia.y = resolve_inertia(
@ -163,8 +175,10 @@ func calculate_velocity(_delta :float,
(calc_acceleration.y * _delta) (calc_acceleration.y * _delta)
) )
else: else:
if is_zero_approx(move_direction.y) == false: ## Using static move directions insteead of inertial move directions
calc_inertia.y = v_speed.x # 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 ## Track or last speed for in range impulses
# _h_impulse_speed_tracking = h_speed # _h_impulse_speed_tracking = h_speed