forked from team-sg/hero-mark-2
fixed issue where player land sound and vibration play on frame 1
This commit is contained in:
parent
b0bb26a81b
commit
948ecb97c7
1 changed files with 11 additions and 5 deletions
|
@ -44,6 +44,8 @@ var snap: Vector2 = Vector2.ZERO
|
|||
var _attached_ladder: Node2D = null
|
||||
# whether to skip blood splatter for this death
|
||||
var skip_blood: bool = false
|
||||
#whether sg has landed before
|
||||
var first_land = true
|
||||
|
||||
|
||||
# NODE REFERENCES #
|
||||
|
@ -163,8 +165,6 @@ func reset_fall_speed():
|
|||
|
||||
# STATE ENTERS/EXITS #
|
||||
func _on_Grounded_state_entered() -> void:
|
||||
#Landing sound
|
||||
Audio.play_sound(Audio.a_land,Audio.ac_land)
|
||||
# still jump if pressed frame hit ground
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
state_chart.send_event("jump")
|
||||
|
@ -172,10 +172,16 @@ func _on_Grounded_state_entered() -> void:
|
|||
grounded_shape.disabled = false
|
||||
airborne_shape.disabled = true
|
||||
snap.y = 2.5 # snap when in grounded state
|
||||
var intensity = inverse_lerp(0.0, max_fall_speed, current_fall_speed)
|
||||
intensity = min(intensity * 1.1,1.0)
|
||||
Input.start_joy_vibration(0, 1.0, intensity, 0.05)
|
||||
velocity.y = 1.0
|
||||
if first_land:
|
||||
first_land = false
|
||||
else:
|
||||
#Landing sound
|
||||
Audio.play_sound(Audio.a_land,Audio.ac_land)
|
||||
#Landing Rumble
|
||||
var intensity = inverse_lerp(0.0, max_fall_speed, current_fall_speed)
|
||||
intensity = min(intensity * 1.1,1.0)
|
||||
Input.start_joy_vibration(0, 1.0, intensity, 0.05)
|
||||
|
||||
func _on_Still_state_entered() -> void:
|
||||
animation_player.play("idle")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue