verifying roll on movement state machine
This commit is contained in:
parent
41eac6ea9b
commit
048c3ff8c1
|
|
@ -31,9 +31,7 @@ var acceleration = Vector2(0,0)
|
||||||
var physics_delta:float
|
var physics_delta:float
|
||||||
var process_delta:float
|
var process_delta:float
|
||||||
|
|
||||||
|
var modifier: StateModifierAnimatedActor
|
||||||
#Can't use floats here, switched to constants.
|
|
||||||
#enum directions {UP = -1, DOWN = 1, LEFT, RIGHT}
|
|
||||||
|
|
||||||
#Removing Probably not used
|
#Removing Probably not used
|
||||||
#var attack_function: FuncRef
|
#var attack_function: FuncRef
|
||||||
|
|
@ -44,12 +42,17 @@ const LEFT = -1.0
|
||||||
const RIGHT = 1.0
|
const RIGHT = 1.0
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
## FuncRef to request state machine change state
|
||||||
request_state_change = funcref(get_node(callable_state_machine), 'change_to_known_state')
|
request_state_change = funcref(get_node(callable_state_machine), 'change_to_known_state')
|
||||||
|
## Connect signal to get alerted of state change
|
||||||
get_node(callable_state_machine).connect("state_changed", self,"_on_state_change")
|
get_node(callable_state_machine).connect("state_changed", self,"_on_state_change")
|
||||||
|
## A reference to the current state machine state
|
||||||
current_state = get_node(callable_state_machine).current_state
|
current_state = get_node(callable_state_machine).current_state
|
||||||
|
## A reference to the state machine merged modifiers
|
||||||
|
modifier = get_node(callable_state_machine).merged_animation_state_modifiers
|
||||||
|
|
||||||
############
|
############
|
||||||
# These get called by the parent
|
## These get called by the parent
|
||||||
############
|
############
|
||||||
func process_physics(delta):
|
func process_physics(delta):
|
||||||
physics_delta = delta
|
physics_delta = delta
|
||||||
|
|
@ -79,7 +82,9 @@ func process_input(event: InputEvent):
|
||||||
|
|
||||||
############
|
############
|
||||||
|
|
||||||
# A Series of helper functions
|
############
|
||||||
|
## A Series of helper functions
|
||||||
|
############
|
||||||
func go_up():
|
func go_up():
|
||||||
desired_movement_vector.y = UP
|
desired_movement_vector.y = UP
|
||||||
func go_down():
|
func go_down():
|
||||||
|
|
@ -114,6 +119,7 @@ func wants_roll() -> bool:
|
||||||
|
|
||||||
func wants_climb() -> bool:
|
func wants_climb() -> bool:
|
||||||
return false
|
return false
|
||||||
|
############
|
||||||
|
|
||||||
func get_climb_shape_location() -> Vector2:
|
func get_climb_shape_location() -> Vector2:
|
||||||
return Vector2(-1,-1)
|
return Vector2(-1,-1)
|
||||||
|
|
@ -194,7 +200,6 @@ func move_actor_as_desired( x_move_direction_override: float = 0):
|
||||||
# #print("doing this? ")
|
# #print("doing this? ")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the maximum move speed
|
# Determine the maximum move speed
|
||||||
var MAX_SPEED :float = 0
|
var MAX_SPEED :float = 0
|
||||||
var MIN_SPEED :float = 0
|
var MIN_SPEED :float = 0
|
||||||
|
|
@ -222,7 +227,7 @@ func move_actor_as_desired( x_move_direction_override: float = 0):
|
||||||
# Perhaps it would be better to trigger this on a difference in modifier but they usually go together.
|
# Perhaps it would be better to trigger this on a difference in modifier but they usually go together.
|
||||||
if abs(acceleration.x) != abs(_move_modifier_move_acceleration + _move_acceleration):
|
if abs(acceleration.x) != abs(_move_modifier_move_acceleration + _move_acceleration):
|
||||||
if move_direction:
|
if move_direction:
|
||||||
print("Acceleration changed.", abs(acceleration.x), "-", (_move_modifier_move_acceleration + _move_acceleration))
|
#print("Acceleration changed.", abs(acceleration.x), "-", (_move_modifier_move_acceleration + _move_acceleration))
|
||||||
acceleration.x = _move_modifier_move_acceleration + _move_acceleration
|
acceleration.x = _move_modifier_move_acceleration + _move_acceleration
|
||||||
|
|
||||||
# If we're no longer tryingg to move int the direction of our movement and momentum.
|
# If we're no longer tryingg to move int the direction of our movement and momentum.
|
||||||
|
|
@ -260,7 +265,7 @@ func move_actor_as_desired( x_move_direction_override: float = 0):
|
||||||
momentum.x = 0
|
momentum.x = 0
|
||||||
elif sign(_move_speed_modifier) == +1: # increased speed modifier
|
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.
|
##TODO: in most cases this should only be applied once. need to find a way to warn against this.
|
||||||
momentum.x = abs(current_state.move_speed_modifier)
|
momentum.x = abs(_move_speed_modifier)
|
||||||
print("momentum applied!")
|
print("momentum applied!")
|
||||||
|
|
||||||
# Reverse the accelerations if we carry over momentum but the modifier no longer applies.
|
# Reverse the accelerations if we carry over momentum but the modifier no longer applies.
|
||||||
|
|
@ -273,6 +278,7 @@ func move_actor_as_desired( x_move_direction_override: float = 0):
|
||||||
|
|
||||||
# We're going to adjust our move speed only to the modifier
|
# We're going to adjust our move speed only to the modifier
|
||||||
momentum.x += acceleration.x * delta
|
momentum.x += acceleration.x * delta
|
||||||
|
##TODO: Apparently I disabled jerk some time ago for some reason.
|
||||||
current_state.jerk += _jerk_factor * delta
|
current_state.jerk += _jerk_factor * delta
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,7 @@ func _ready():
|
||||||
# animation = 'idle-attack-sword'
|
# animation = 'idle-attack-sword'
|
||||||
|
|
||||||
func _on_state_change_fall():
|
func _on_state_change_fall():
|
||||||
change_animation()
|
change_animation(2)
|
||||||
frame = 2
|
|
||||||
stop()
|
stop()
|
||||||
|
|
||||||
func _on_state_exited_attack_sword():
|
func _on_state_exited_attack_sword():
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ script = ExtResource( 1 )
|
||||||
debug_state = false
|
debug_state = false
|
||||||
timeout_seconds = 0.0
|
timeout_seconds = 0.0
|
||||||
name = "roll"
|
name = "roll"
|
||||||
horizontal_speed = 60.0
|
horizontal_speed = 10.0
|
||||||
horizontal_acceleration = 0.0
|
horizontal_acceleration = 1.36422e-12
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 150.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = -150.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
animation_sequence = [ "roll" ]
|
animation_sequence = [ "roll" ]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user