Fixup for states for player and spider animation. Cleanup useless movement state comments.

This commit is contained in:
Nitsud Yarg 2024-07-21 08:55:14 -07:00
parent 48f3e631e6
commit 2ff08298b7
4 changed files with 13 additions and 37 deletions

View File

@ -8,7 +8,7 @@ func _ready():
landing_modifier= StateModifier.new()
#add_child(modifier)
#modifier.init_ref()
landing_modifier.ready( "landing", "jump" , landing_modifier.TYPE.EXIT_ANIMATION)
landing_modifier.ready( "landing", "land" , landing_modifier.TYPE.EXIT_ANIMATION)
#print("ready! MOD")

View File

@ -633,7 +633,8 @@ idle_node = NodePath("../idle")
script = ExtResource( 11 )
move_speed = 90.0
move_speed_modifier = 90.0
move_modifier_move_acceleration = -180.0
move_modifier_move_acceleration = -100.0
jerk_factor = -20.0
animation_sequence = [ "dash" ]
fall_node = NodePath("../fall")
idle_node = NodePath("../idle")

View File

@ -47,7 +47,7 @@ func process_frame(delta: float) -> State:
func process_physics(delta: float) -> State:
move_component.velocity.y += gravity * delta
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
move_component.velocity = parent.transform.x * move_speed
move_component.velocity.x = parent.transform.x.x * move_speed
# if (parent.direction.x > 0):
# parent.velocity.x = 1 * move_speed
# else:

View File

@ -353,12 +353,6 @@ func move_actor_as_desired(delta: float, x_move_direction_override: float = 0):
print("Acceleration changed.", abs(move_component.acceleration.x), "-", (_move_modifier_move_acceleration + _move_acceleration))
move_component.acceleration.x = _move_modifier_move_acceleration + _move_acceleration
# ##TODO: I don't know where I should actually set the momentum. :
# if sign(_move_speed_modifier) == -1: # decreased speed modifier
# move_component.momentum.x = 0
# elif sign(_move_speed_modifier) == +1: # increased speed modifier
# move_component.momentum.x = abs(move_speed_modifier)
# If we're no longer tryingg to move int the direction of our movement and momentum.
if sign(current_x_velocity) != sign(move_component.desired_movement_vector.x) and move_component.momentum.x != 0:
if sign(_move_speed_modifier) == -1 : # decreased speed modifier
@ -375,13 +369,15 @@ func move_actor_as_desired(delta: float, x_move_direction_override: float = 0):
sign(current_x_velocity) == 1) or (sign(move_component.desired_movement_vector.x) == -1 and
sign(current_x_velocity) == -1):
print("be more opposite")
if sign(_move_speed_modifier) == 1:
print("faster faster.")
# if sign(_move_speed_modifier) == 1: # increased speed modifier
# print("faster faster.")
elif sign(move_component.desired_movement_vector.x) == sign(current_x_velocity) and move_component.momentum.x != 0:
if sign(move_component.acceleration.x) != sign(move_component.momentum.x) and x_move_direction_override == 0:
print("Step it up!")
# Flip the direction of the acceleration
move_component.acceleration.x *= -1
# Apply momentum and acceleration if a modifer exists
if move_component.momentum.x <= 0 and _move_speed_modifier !=0:
#if we're trying to move but we have no momentum applied currently
#if move_component.desired_movement_vector.x != 0:
@ -391,43 +387,22 @@ func move_actor_as_desired(delta: float, x_move_direction_override: float = 0):
if sign(_move_speed_modifier) == -1: # decreased speed modifier
move_component.momentum.x = 0
elif sign(_move_speed_modifier) == +1: # increased speed modifier
##TODO: in most cases this should only be applied once. need to find a way to warn against this.
move_component.momentum.x = abs(move_speed_modifier)
print("momentum applied!")
# Reverse the accelerations if we carry over momentum but the modifier no longer applies.
if move_component.momentum.x > 0 and _move_speed_modifier == 0:
if sign(move_component.acceleration.x) == sign(move_component.momentum.x):
print("Whoh Woah your done.")
# Flip the direction of the acceleration
move_component.acceleration.x *= -1
##TODO: I don't know where I should actually set the momentum. :
# This was not the place
# if sign(_move_speed_modifier) == -1: # decreased speed modifier
# move_component.momentum.x = 0
# move_component.acceleration.x = _move_modifier_move_acceleration + _move_acceleration
# elif sign(_move_speed_modifier) == +1: # increased speed modifier
# move_component.momentum.x = abs(move_speed_modifier)
# elif sign(_move_speed_modifier) == +1: # increased speed modifier
# print("wait does it matter")
# else: # physics won't apply here
# print("uh")
# else:
# print("Direction changed")
# if move_component.momentum.x > abs(current_x_velocity):
# move_component.momentum.x = abs(current_x_velocity)
# flip the acceleration to apply against the momentum
#move_component.acceleration.x *= -1 * sign(move_component.momentum.x)
# If the movement direction changes and we have momentum
# print("Flip that thing!")
# move_component.momentum.x *= -1
# if sign(move_component.acceleration.x ) == sign(_move_speed_modifier):
# move_component.acceleration.x *= -1 * sign(current_x_velocity)
# We're going to adjust our move speed only to the modifier
move_component.momentum.x += move_component.acceleration.x * delta
jerk += _jerk_factor * delta
# Momentum should always be the inverse of the speed modifier
var new_move_speed :float = 0
if sign(_move_speed_modifier) == -1: # decreased speed modifier
@ -453,7 +428,7 @@ func move_actor_as_desired(delta: float, x_move_direction_override: float = 0):
var sim_move_speed = (MIN_SPEED + (sign(_move_speed_modifier) * -1 * move_component.momentum.x))
# if move_component.momentum.x != 0:
if false:
if true:
UiManager.debug_text = ( "Mod(" + str(sign(_move_speed_modifier)) + ") Dir(" + str(move_direction) + ") Vel(" + str(sign(current_x_velocity)) + ") Mov(" + str(sign(move_component.desired_movement_vector.x)) +
")\nNS:" + str(round(sim_move_speed)) + #" Z:" + str(sign(_move_speed_modifier) * -1 * move_component.momentum.x) +
"\nS:" + str(round(_move_speed + _move_speed_modifier)) + ",M" + str(round(move_component.momentum.x)) +