forked from team-sg/hero-mark-2
fixed ducking bug duckbug.... ぶ
This commit is contained in:
parent
02793ddc38
commit
ba4e603f2b
3 changed files with 273 additions and 7 deletions
|
@ -42,7 +42,7 @@ func _physics_process(delta: float) -> void:
|
|||
State.DEAD:
|
||||
return
|
||||
State.STAND:
|
||||
if Input.is_action_pressed("move_down") and energy >= duck_energy:
|
||||
if sign(Input.get_axis("move_up", "move_down") + get_stick_input(JOY_AXIS_1)) == 1 and energy >= duck_energy:
|
||||
state = State.DUCK
|
||||
anims.play("Duck")
|
||||
elif Input.is_action_pressed("move_right"):
|
||||
|
@ -52,7 +52,7 @@ func _physics_process(delta: float) -> void:
|
|||
state = State.BACK
|
||||
anims.play("Walk", -1.0, -1.0, true)
|
||||
State.DUCK:
|
||||
if not Input.is_action_pressed("move_down") and anims.current_animation.empty():
|
||||
if (!Input.is_action_pressed("move_down") && get_stick_input(JOY_AXIS_1) != 1) and anims.current_animation.empty():
|
||||
anims.play("UnDuck")
|
||||
energy -= duck_energy
|
||||
|
||||
|
@ -73,6 +73,12 @@ func _input(event: InputEvent) -> void:
|
|||
if event.is_action_pressed("jump") and state == State.STAND and energy >= beam_energy:
|
||||
beam()
|
||||
|
||||
func get_stick_input(axis):
|
||||
var inp = Input.get_joy_axis(0,axis)
|
||||
if abs(inp) >= 0.5:
|
||||
return sign(inp)
|
||||
else:
|
||||
return 0
|
||||
|
||||
func set_energy(value: float) -> void:
|
||||
energy = clamp(value, 0.0, max_energy)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue