Steps dans le son

This commit is contained in:
MarcEricMartel
2022-10-11 16:32:48 -04:00
parent 14e14d5929
commit c3a32c5176
15 changed files with 181 additions and 6 deletions

View File

@@ -10,7 +10,9 @@ export var jump = 30
export var slapkill = 0.8
var slap = 0.0
var chargeSlap = false
var isSlap = false;
var isSlap = false
var isStep = false
var stepAcc = 0
export var mouse_sensitivity = 0.03
@@ -29,8 +31,11 @@ onready var slap_animator = $HandMovement
onready var Menu = $HUD/Start
onready var AudioSlap = $AudioSlap
onready var AudioMegaSlap = $AudioMegaSlap
onready var Steps = [ $Step1, $Step2, $Step3, $Step4 ]
var rng = RandomNumberGenerator.new()
func _ready():
rng.randomize()
slap_animator.current_animation = "basic_slap"
@@ -61,12 +66,15 @@ func _physics_process(delta):
elif is_on_floor() and full_contact:
gravity_vec = -get_floor_normal() * gravity
h_acceleration = normal_acceleration
isStep = true
else:
gravity_vec = -get_floor_normal()
h_acceleration = normal_acceleration
if Input.is_action_just_pressed("jump") and (is_on_floor() or ground_check.is_colliding()):
gravity_vec = Vector3.UP * jump
isStep = false
if Input.is_action_pressed("move_forward"):
direction -= transform.basis.z
@@ -77,6 +85,7 @@ func _physics_process(delta):
elif Input.is_action_pressed("move_right"):
direction += transform.basis.x
# Slappening
if Input.is_action_pressed("slap"):
if slap < 0.01:
@@ -104,9 +113,19 @@ func _physics_process(delta):
slap_animator.seek(slap, true)
slap_gauge.fill = slap;
slap_gauge.kill = slapkill;
direction = direction.normalized()
if isStep:
stepAcc += (abs(direction.x) + abs(direction.z)) * delta
else:
stepAcc = 0.0
if (stepAcc > 0.3):
stepAcc -= 0.45
Steps[rng.randi_range(0,3)].play();
h_velocity = h_velocity.linear_interpolate(direction * speed, h_acceleration * delta)
movement.z = h_velocity.z + gravity_vec.z
movement.x = h_velocity.x + gravity_vec.x