started work on moving collision layers and added jump and land sounds
This commit is contained in:
@@ -7,6 +7,8 @@ var gravity = 9.8
|
||||
var is_climbing = false
|
||||
var ladder_center
|
||||
var default_gravity = gravity
|
||||
var moving_fast = false
|
||||
var moving_fast_top_speed = 0.0
|
||||
var mouse_input : Vector2
|
||||
|
||||
var rng = RandomNumberGenerator.new()
|
||||
@@ -77,6 +79,7 @@ var pickupmsg
|
||||
@onready var world_environment = $"../WorldEnvironment"
|
||||
@onready var pickup_sound = $Audio/PickupSound
|
||||
@onready var ear_wind = $Audio/EarWind
|
||||
@onready var land_sound: AudioStreamPlayer = $Audio/LandSound
|
||||
@onready var hurt_audio = $Audio/Hurt
|
||||
@onready var health_indicator = $HealthIndicator
|
||||
@onready var ammo_counter = $Head/Camera3D/AmmoCounter
|
||||
@@ -169,8 +172,31 @@ func _physics_process(delta):
|
||||
var health_opacity = 1.5 - level_control.health / level_control.start_health
|
||||
health_indicator.color = lerp(Color(0.471, 0, 0, 0), Color(0.471, 0, 0, .25),health_opacity)
|
||||
|
||||
# Land sound
|
||||
|
||||
# Moving Fast Sound
|
||||
#initiate fast movement
|
||||
if velocity.y >= JUMP_VELOCITY and !moving_fast:
|
||||
moving_fast = true
|
||||
ear_wind.play()
|
||||
#change sounds with speed
|
||||
if moving_fast:
|
||||
var wind_volume = clamp( velocity.length() - 20 ,-20,0)
|
||||
ear_wind.volume_db = wind_volume
|
||||
#reset at apex
|
||||
if abs(velocity.y) < 0:
|
||||
moving_fast_top_speed = 0.0
|
||||
#cache fastest speed
|
||||
if abs(velocity.y) > moving_fast_top_speed:
|
||||
moving_fast_top_speed = abs(velocity.y)
|
||||
print("TOP SPEED = " + str(moving_fast_top_speed))
|
||||
#Land Sound
|
||||
if velocity.y < .1 and self.is_on_floor() and moving_fast == true:
|
||||
print("LAND SOUND")
|
||||
var land_volume = clamp( moving_fast_top_speed - 20 ,-20,0)
|
||||
land_sound.volume_db = land_volume
|
||||
land_sound.play()
|
||||
ear_wind.stop()
|
||||
moving_fast_top_speed = 0.0
|
||||
moving_fast = false
|
||||
|
||||
# Game Speed
|
||||
if Input.is_action_pressed("slow_down") and remaining_stamina >0:
|
||||
@@ -233,9 +259,10 @@ func _physics_process(delta):
|
||||
|
||||
#interact button
|
||||
if Input.is_action_just_pressed("interact"):
|
||||
if interact_ray.is_colliding(): # and !interact_ray.get_collider().is_in_group("interact"):
|
||||
var body = interact_ray.get_collider()
|
||||
body.get_parent().interact()
|
||||
if interact_ray.is_colliding():
|
||||
if interact_ray.get_collider().is_in_group("interact"):
|
||||
var body = interact_ray.get_collider()
|
||||
body.get_parent().interact()
|
||||
|
||||
|
||||
#quit game and eventually go to menu
|
||||
|
||||
Reference in New Issue
Block a user