Movement modifier has grounded processing directives.

This commit is contained in:
Dustin 2025-05-04 08:05:27 -07:00
parent 7d7f3dfcd6
commit b45272934f
7 changed files with 23 additions and 3 deletions

View File

@ -199,9 +199,12 @@ func new_move_actor_as_desired(_delta :float,
impulse_applied_dir = sign(move_direction.x)
var modifier_indicator := ''
var movement_parameters :MovementParameters = _state.get_movement_parameters()
if modifier and modifier.is_active:
movement_parameters.apply_state_modifier(modifier, move_direction.x)
if !(_state.is_grounded and modifier.only_grounded): # Should we skip
modifier_indicator = '*'
movement_parameters.apply_state_modifier(modifier, move_direction.x)
## Inertia only applies if there is a difference between the
# base move speed and a derived move speed. This makes it so all you
@ -331,7 +334,7 @@ func new_move_actor_as_desired(_delta :float,
#calc_inertial_dir = Vector2(sign(calc_velocity.x),sign(calc_velocity.y))
UiManager.debug_text = ( #"H_Speed x Dir: " + str(h_speed) + str('duh') +
"H_Speed Fm:{0} To:{1}".format({"0":"%5.2f" % h_speed.x, "1":"%5.2f" % h_speed.y}) +
modifier_indicator + "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}) +
"\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}) +

View File

@ -27,6 +27,9 @@ export var vertical_speed_offset_acceleration: float = 0
## Should this state keep the inertia from previous states
export var preserve_inertia :bool = true
## Whether this state should be considered a grounded state
export var is_grounded :bool = true
## Default state gravity is the project's gravity
var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")

View File

@ -21,6 +21,7 @@ var gravity: int = 0
## Processing Directives (help determine how the merge function works)
var direction :float = 0.0 # -1, 0, 1
var only_grounded :float = false
enum SUB_TYPE {
NONE, # Basic physics modifier just adds numbers

View File

@ -306,6 +306,7 @@ func _state_process_physics_jump():
if velocity.y > 0:
request_state_change.call_func('fall')
move_actor_as_desired()
#apply_movement_to_parent(new_move_actor_as_desired( physics_delta , current_state ))
func _state_process_physics_move():
# flip sprite in direction
@ -443,7 +444,6 @@ func _state_process_physics_crouch_move():
# print("Movement State Idle State Entered!")
func _on_state_entered_jump():
print ("how many times do I get called?")
##TODO: Make this a state export variable
# I used to call it 'jump_force' like an idiot.
velocity.y = -200

View File

@ -72,6 +72,7 @@ func _ready():
tired_debuff_modifier.setup('so_tired', StateModifierMovement.SUB_TYPE.NEGATIVE_CONSTRAINT)
tired_debuff_modifier.horizontal_speed = -40
tired_debuff_modifier.only_grounded = true
movement_state_machine.push_state_modifier(tired_debuff_modifier)
#var stamina_recovery :float = 0.0

View File

@ -14,4 +14,10 @@ horizontal_acceleration = 0.0
horizontal_speed_offset = 0.0
horizontal_speed_offset_acceleration = 0.0
jerk_factor = 0.0
vertical_speed = 0.0
vertical_acceleration = 0.0
vertical_speed_offset = 0.0
vertical_speed_offset_acceleration = 0.0
preserve_inertia = true
is_grounded = false
animation_sequence = [ "jump" ]

View File

@ -14,4 +14,10 @@ horizontal_acceleration = 0.0
horizontal_speed_offset = 0.0
horizontal_speed_offset_acceleration = 0.0
jerk_factor = 0.0
vertical_speed = 0.0
vertical_acceleration = 0.0
vertical_speed_offset = 0.0
vertical_speed_offset_acceleration = 0.0
preserve_inertia = true
is_grounded = false
animation_sequence = [ "jump" ]