Hey Skydome,
one way would be to check if the player is already walking in a given direction:
var walks = null
func _process(delta):
if Input.is_action_just_pressed("walk_up"):
if walks == "up":
speed = 200
else:
speed = 100
walks = "up"
elif Input.is_action_just_pressed("walk_down"):
if walks == "down":
speed = 200
else:
speed = 100
walks = "down"
# ...
NOTE: This way the player could wait infinitely before pressing the second time. You could use a timer to reset the walks variable like in the example below.
Another way would be to have a list of actions that were done before:
var actions = []
var timer = Timer.new()
func _ready():
timer.one_shot = true
timer.connect("timeout", self, "delete_action_history")
func _process(delta):
if Input.is_action_just_pressed("walk_up"):
if actions.back() == "walked_up":
#run up
else:
#walk up
do_action("walked_up", 1)
#...
func do_action(action, time)
timer.stop()
timer.wait_time(time)
action.append(action)
func delete_action_history():
actions = []
This system would be more advanced and could be easily adapted to more complex combinations as it would also allow to create something like this:
if Input.is_action_just_pressed("jump"):
if ("jumped" in actions) and ("ate_berry" in actions):
# jump again
This will allow your player to make another jump if he ate a berry during his jump.
It's not completely perfect but it might give you a hint how you could do such a thing. Hope it helps.