Modifier tweaks on dash to model over to usual movement.

This commit is contained in:
Nitsud Yarg 2024-06-29 15:56:06 -07:00
parent 38696b9398
commit 2b08e37337
4 changed files with 19 additions and 10 deletions

View File

@ -148,8 +148,9 @@ script = ExtResource( 12 )
[node name="Debug" type="Label" parent="UI_Layer"] [node name="Debug" type="Label" parent="UI_Layer"]
anchor_left = 1.0 anchor_left = 1.0
anchor_right = 1.0 anchor_right = 1.0
margin_left = -64.0 margin_left = -192.0
margin_top = 3.0 margin_top = 3.0
margin_right = -3.0 margin_right = -3.0
margin_bottom = 17.0 margin_bottom = 17.0
text = "Foo" text = "Foo"
align = 2

View File

@ -604,6 +604,7 @@ jump_force = 250.0
[node name="attack" type="Node" parent="movement_state_machine" index="4"] [node name="attack" type="Node" parent="movement_state_machine" index="4"]
script = ExtResource( 10 ) script = ExtResource( 10 )
timeout_seconds = 1.5 timeout_seconds = 1.5
move_speed = 90.0
animation_sequence = [ "shoot" ] animation_sequence = [ "shoot" ]
jump_node = NodePath("../jump") jump_node = NodePath("../jump")
idle_node = NodePath("../idle") idle_node = NodePath("../idle")
@ -620,8 +621,8 @@ idle_node = NodePath("../idle")
[node name="dash" type="Node" parent="movement_state_machine" index="6"] [node name="dash" type="Node" parent="movement_state_machine" index="6"]
script = ExtResource( 11 ) script = ExtResource( 11 )
move_speed = 90.0 move_speed = 90.0
move_speed_modifier = 120.0 move_speed_modifier = 150.0
move_speed_modifier_decay = -300.0 move_modifier_move_acceleration = -400.0
animation_sequence = [ "dash" ] animation_sequence = [ "dash" ]
fall_node = NodePath("../fall") fall_node = NodePath("../fall")
idle_node = NodePath("../idle") idle_node = NodePath("../idle")

View File

@ -10,15 +10,17 @@ onready var fall_state: State = get_node(fall_node)
onready var idle_state: State = get_node(idle_node) onready var idle_state: State = get_node(idle_node)
onready var attack_state: State = get_node(attack_node) onready var attack_state: State = get_node(attack_node)
var speed_decay_rate := 1.0 #var speed_decay_rate := 1.0
var adjusted_move_speed: float var adjusted_move_speed: float
var jerk: float
func enter(): func enter():
#remove_animation_state_modifiers() #remove_animation_state_modifiers()
.enter() .enter()
adjusted_move_speed = move_speed_modifier adjusted_move_speed = move_speed_modifier
speed_multiplier = 5 jerk = 0
speed_decay_rate = 4 # speed_multiplier = 5
# speed_decay_rate = 4
func process_physics(delta: float) -> State: func process_physics(delta: float) -> State:
@ -31,8 +33,9 @@ func process_physics(delta: float) -> State:
# Assuming adjusted_move_speed is set to the mood speed modifier on state entry # Assuming adjusted_move_speed is set to the mood speed modifier on state entry
# Move speed is the base speed plus the modifier minus the decay adjusted for time # Move speed is the base speed plus the modifier minus the decay adjusted for time
adjusted_move_speed = adjusted_move_speed + (move_speed_modifier_decay * delta) jerk += jerk_factor * delta
var new_move_speed = move_speed + adjusted_move_speed adjusted_move_speed = adjusted_move_speed + (move_modifier_move_acceleration * delta)
var new_move_speed = move_speed + (move_acceleration * delta) + adjusted_move_speed + jerk
# A really crappy normalization to prevent modifying past the base move speed. # A really crappy normalization to prevent modifying past the base move speed.
if move_speed_modifier > 0 and new_move_speed < move_speed: # positive modifier if move_speed_modifier > 0 and new_move_speed < move_speed: # positive modifier
@ -41,6 +44,9 @@ func process_physics(delta: float) -> State:
elif move_speed_modifier < 0 and new_move_speed > move_speed: # negative modifier elif move_speed_modifier < 0 and new_move_speed > move_speed: # negative modifier
#print("nope2") #print("nope2")
new_move_speed = move_speed new_move_speed = move_speed
else:
UiManager.debug_text = str(round(adjusted_move_speed)) + "," + str(round(new_move_speed)) + "," + str(round(jerk))
#print(adjusted_move_speed, ",", new_move_speed, ",", jerk)
#print(new_move_speed, " ", adjusted_move_speed) #print(new_move_speed, " ", adjusted_move_speed)

View File

@ -18,9 +18,10 @@ extends State
# Movement Speed in Pixels Per Second # Movement Speed in Pixels Per Second
export var move_speed: float = 60 export var move_speed: float = 60
export var move_speed_decay: float = 0 export var move_acceleration: float = 0
export var move_speed_modifier: float = 0 export var move_speed_modifier: float = 0
export var move_speed_modifier_decay: float = 0 export var move_modifier_move_acceleration: float = 0
export var jerk_factor: float = 0
var speed_multiplier: float = 1.0 var speed_multiplier: float = 1.0
export(Array, String) var animation_sequence export(Array, String) var animation_sequence