Running.
This commit is contained in:
parent
702782def7
commit
522e409dab
|
|
@ -2,11 +2,12 @@ extends AnimatedSprite_StateReceiver
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
# Lets see if this nutty thing works
|
# Lets see if this nutty thing works
|
||||||
var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
|
var state_ref :State
|
||||||
state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
# state_ref = get_node(callable_state_machine).get_state_reference('idle')
|
||||||
|
# state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
||||||
|
|
||||||
# state_ref = get_node(callable_state_machine).get_state_reference('fall')
|
state_ref = get_node(callable_state_machine).get_state_reference('fall')
|
||||||
# state_ref.connect("state_entered", self, "_on_state_entered_fall")
|
state_ref.connect("state_entered", self, "_on_state_entered_fall")
|
||||||
# It works but node order really mattered.
|
# It works but node order really mattered.
|
||||||
# State machine needed to be processed first probably for ready function.
|
# State machine needed to be processed first probably for ready function.
|
||||||
# good to know!
|
# good to know!
|
||||||
|
|
@ -18,8 +19,8 @@ func _ready():
|
||||||
#func _state_process_fall():
|
#func _state_process_fall():
|
||||||
# print("I got called!")
|
# print("I got called!")
|
||||||
|
|
||||||
func _on_state_entered_idle():
|
#func _on_state_entered_idle():
|
||||||
print("Anim Knows Idle State Entered!")
|
# print("Anim Knows Idle State Entered!")
|
||||||
|
|
||||||
func _on_state_entered_fall():
|
func _on_state_entered_fall():
|
||||||
print("Anim Knows Fall State Entered!")
|
print("Anim Knows Fall State Entered!")
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,34 @@
|
||||||
extends Movement_StateReceiver
|
extends Movement_StateReceiver
|
||||||
|
|
||||||
func _ready():
|
#func _ready():
|
||||||
# Lets see if this nutty thing works
|
# Lets see if this nutty thing works
|
||||||
var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
|
# var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
|
||||||
state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
# state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
||||||
# It works but node order really mattered.
|
# It works but node order really mattered.
|
||||||
# State machine needed to be processed first probably for ready function.
|
# State machine needed to be processed first probably for ready function.
|
||||||
# good to know!
|
# good to know!
|
||||||
|
|
||||||
|
var player_number: int = 1
|
||||||
|
|
||||||
|
func get_movement_direction() -> float:
|
||||||
|
#return Input.get_axis('move_left', 'move_right')
|
||||||
|
desired_movement_vector.x = Input.get_axis("move_left_" + str(player_number), "move_right_" + str(player_number))
|
||||||
|
return Input.get_axis("move_left_" + str(player_number), "move_right_" + str(player_number))
|
||||||
|
|
||||||
|
#TODO: This is probably not a good way to do this.
|
||||||
|
# we want to check input once and make decisions based on
|
||||||
|
# velocity and desired movement.
|
||||||
|
func _state_process_physics_input_idle():
|
||||||
|
get_movement_direction()
|
||||||
|
|
||||||
|
func _state_process_physics_input_move():
|
||||||
|
get_movement_direction()
|
||||||
|
|
||||||
func _state_process_physics_idle():
|
func _state_process_physics_idle():
|
||||||
|
#TODO: May need that 'bump' logic to make velocity work.
|
||||||
|
if desired_movement_vector.x != 0: # and velocity.x != 0:
|
||||||
|
request_state_change.call_func('move')
|
||||||
|
|
||||||
if !parent.is_on_floor():
|
if !parent.is_on_floor():
|
||||||
#return fall_state
|
#return fall_state
|
||||||
request_state_change.call_func('fall')
|
request_state_change.call_func('fall')
|
||||||
|
|
@ -22,6 +42,17 @@ func _state_process_physics_fall():
|
||||||
#idle_state.modifier = landing_modifier
|
#idle_state.modifier = landing_modifier
|
||||||
request_state_change.call_func('idle')
|
request_state_change.call_func('idle')
|
||||||
|
|
||||||
|
func _state_process_physics_move():
|
||||||
|
# flip sprite in direction
|
||||||
|
if get_movement_direction() != 0.0:
|
||||||
|
parent.transform.x.x = get_movement_direction()
|
||||||
|
|
||||||
|
if desired_movement_vector.x == 0:
|
||||||
|
request_state_change.call_func('idle')
|
||||||
|
|
||||||
|
if !parent.is_on_floor():
|
||||||
|
request_state_change.call_func('fall')
|
||||||
|
|
||||||
#func _on_state_entered_idle():
|
#func _on_state_entered_idle():
|
||||||
# print("Movement State Idle State Entered!")
|
# print("Movement State Idle State Entered!")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user