Super slippy walk working again!

This commit is contained in:
Dustin 2025-04-27 09:37:40 -07:00
parent d4077cff43
commit 5ecbbccf7e
3 changed files with 23 additions and 16 deletions

View File

@ -181,6 +181,7 @@ func new_move_actor_as_desired(_delta :float,
else: else:
move_direction = resolve_move_direction(calc_inertial_dir, desired_movement_vector) move_direction = resolve_move_direction(calc_inertial_dir, desired_movement_vector)
## Which direction will acceleration be applied.
calc_acceleration.x = resolve_h_acceleration(movement_params, h_speed, move_direction.x) calc_acceleration.x = resolve_h_acceleration(movement_params, h_speed, move_direction.x)
## Direction of inertia not equal to move direction ## Direction of inertia not equal to move direction
@ -188,7 +189,10 @@ func new_move_actor_as_desired(_delta :float,
if calc_inertial_dir.x: if calc_inertial_dir.x:
## And it doesn't apply in the same direction as our movement direction ## And it doesn't apply in the same direction as our movement direction
if calc_inertial_dir.x != sign(move_direction.x): if calc_inertial_dir.x != sign(move_direction.x):
## flip the direction of acceleration and apply as friction ## Apply the direction of acceleration and apply as friction
# Friction allows the inertia to trend toward 0 instead of the
# 'To' direction of speed.
##
#calc_friction.x = calc_acceleration.x * -1 #calc_friction.x = calc_acceleration.x * -1
calc_friction.x = calc_acceleration.x calc_friction.x = calc_acceleration.x
calc_acceleration.x = 0.0 calc_acceleration.x = 0.0
@ -230,24 +234,27 @@ func new_move_actor_as_desired(_delta :float,
# calc_inertia.x, h_speed.y) # calc_inertia.x, h_speed.y)
elif calc_inertia.x != 0.0: ## We still have inertia but no difference in movement elif calc_inertia.x != 0.0: ## We still have inertia but no difference in movement
if calc_acceleration.x != 0.0: # We are applying acceleration if calc_acceleration.x != 0.0: # We are applying acceleration
if calc_inertia.x > h_speed.x: ## Move back towards the base speed
calc_inertia.x = clamp( calc_inertia.x + ( calc_acceleration.x * _delta), calc_inertia.x = move_toward(calc_inertia.x, h_speed.x, ( calc_acceleration.x * _delta))
calc_inertia.x, h_speed.x) # if calc_inertia.x > h_speed.x:
else: # calc_inertia.x = clamp( calc_inertia.x + ( calc_acceleration.x * _delta),
calc_inertia.x = clamp( calc_inertia.x + ( calc_acceleration.x * _delta), # calc_inertia.x, h_speed.x)
h_speed.x, calc_inertia.x) # else:
# calc_inertia.x = clamp( calc_inertia.x + ( calc_acceleration.x * _delta),
# h_speed.x, calc_inertia.x)
else: ## No longer applying acceleration else: ## No longer applying acceleration
## Neutralize the inertia? but how? ## Neutralize the inertia? but how?
## Recalc the acceleration with inertia ## Recalc the acceleration with inertia
#var friction :Vector2 #var friction :Vector2
calc_friction.x = resolve_h_acceleration(movement_params,Vector2(calc_inertia.x, h_speed.x), move_direction.x) calc_friction.x = resolve_h_acceleration(movement_params,Vector2(calc_inertia.x, h_speed.x), move_direction.x)
if calc_friction.x != 0.0: ## No dapening acceleration applies if calc_friction.x != 0.0: ## No dapening acceleration applies
if calc_inertia.x > h_speed.x: ## Inertia is higher than the base speed (slow it down) calc_inertia.x = move_toward(calc_inertia.x, h_speed.x, ( calc_friction.x * _delta))
calc_inertia.x = clamp( calc_inertia.x + ( calc_friction.x * _delta), # if calc_inertia.x > h_speed.x: ## Inertia is higher than the base speed (slow it down)
h_speed.x, calc_inertia.x) # calc_inertia.x = clamp( calc_inertia.x + ( calc_friction.x * _delta),
else: ## Inertia lower than base speed (we need to catch up) # h_speed.x, calc_inertia.x)
calc_inertia.x = clamp( calc_inertia.x + ( calc_friction.x * _delta), # else: ## Inertia lower than base speed (we need to catch up)
calc_inertia.x, h_speed.x) # calc_inertia.x = clamp( calc_inertia.x + ( calc_friction.x * _delta),
# calc_inertia.x, h_speed.x)
else: else:
## no residual acceleration (friction) applies, kill the momentum ## no residual acceleration (friction) applies, kill the momentum
calc_inertia.x = 0.0 calc_inertia.x = 0.0
@ -284,7 +291,7 @@ func new_move_actor_as_desired(_delta :float,
#calc_inertial_dir = Vector2(sign(calc_velocity.x),sign(calc_velocity.y)) #calc_inertial_dir = Vector2(sign(calc_velocity.x),sign(calc_velocity.y))
UiManager.debug_text = ( #"H_Speed x Dir: " + str(h_speed) + str('duh') + UiManager.debug_text = ( #"H_Speed x Dir: " + str(h_speed) + str('duh') +
"H_Speed: {0}, {1}".format({"0":"%5.2f" % h_speed.x, "1":"%5.2f" % h_speed.y}) + "H_Speed Fm:{0} To:{1}".format({"0":"%5.2f" % h_speed.x, "1":"%5.2f" % h_speed.y}) +
"\nVelocity_Calc: {0}, {1}".format({"0":"%5.2f" % calc_velocity.x, "1":"%5.2f" % calc_velocity.y}) + "\nVelocity_Calc: {0}, {1}".format({"0":"%5.2f" % calc_velocity.x, "1":"%5.2f" % calc_velocity.y}) +
"\nInertia_Calc: {0}, {1}".format({"0":"%5.2f" % calc_inertia.x, "1":"%5.2f" % calc_inertia.y}) + "\nInertia_Calc: {0}, {1}".format({"0":"%5.2f" % calc_inertia.x, "1":"%5.2f" % calc_inertia.y}) +
"\nVelocity_Real: {0}, {1}".format({"0":"%5.2f" % velocity.x, "1":"%5.2f" % velocity.y}) + "\nVelocity_Real: {0}, {1}".format({"0":"%5.2f" % velocity.x, "1":"%5.2f" % velocity.y}) +

View File

@ -10,7 +10,7 @@ debug_state = false
timeout_seconds = 0.0 timeout_seconds = 0.0
name = "idle" name = "idle"
horizontal_speed = 1.36422e-12 horizontal_speed = 1.36422e-12
horizontal_acceleration = 2.0 horizontal_acceleration = -2.0
horizontal_speed_offset = 0.0 horizontal_speed_offset = 0.0
horizontal_speed_offset_acceleration = 0.0 horizontal_speed_offset_acceleration = 0.0
jerk_factor = 0.0 jerk_factor = 0.0

View File

@ -12,6 +12,6 @@ name = "roll"
horizontal_speed = 150.0 horizontal_speed = 150.0
horizontal_acceleration = 1.36422e-12 horizontal_acceleration = 1.36422e-12
horizontal_speed_offset = -140.0 horizontal_speed_offset = -140.0
horizontal_speed_offset_acceleration = 30.0 horizontal_speed_offset_acceleration = 50.0
jerk_factor = 0.0 jerk_factor = 0.0
animation_sequence = [ "roll" ] animation_sequence = [ "roll" ]