added working vending machine
This commit is contained in:
@@ -33,7 +33,7 @@ var start_sensitivity
|
||||
|
||||
@onready var gun_ray = $Head/Camera3D/GunRay
|
||||
@onready var level_control = $".."
|
||||
|
||||
@onready var interact_ray = $Head/Camera3D/InteractRay
|
||||
@onready var bullet_ray = $Head/Camera3D/BulletRay
|
||||
var instance_bullet
|
||||
var instance_casing
|
||||
@@ -67,6 +67,7 @@ var pickupmsg
|
||||
@onready var pickup_sound = $Audio/PickupSound
|
||||
@onready var ear_wind = $Audio/EarWind
|
||||
@onready var weapon_spawner = $Head/Camera3D/WeaponHolder/WeaponSpawner
|
||||
@onready var pick_up_detection = $pick_up_detection
|
||||
|
||||
|
||||
func _ready():
|
||||
@@ -114,11 +115,11 @@ func _physics_process(delta):
|
||||
velocity.x = direction.x * speed
|
||||
velocity.z = direction.z * speed
|
||||
else:
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 3.0)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * 3.0)
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5)
|
||||
else:
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 3.0)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * 3.0)
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5)
|
||||
|
||||
# Head bob
|
||||
t_bob += delta * velocity.length() * float(is_on_floor())
|
||||
@@ -188,8 +189,16 @@ func _physics_process(delta):
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(level_control.current_gun_index - 1)
|
||||
|
||||
|
||||
#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()
|
||||
|
||||
|
||||
#quit game and eventually go to menu
|
||||
if Input.is_action_pressed("escape"):
|
||||
if Input.is_action_just_pressed("escape"):
|
||||
get_tree().quit()
|
||||
|
||||
move_and_slide()
|
||||
@@ -205,6 +214,7 @@ func _headbob(time) -> Vector3:
|
||||
|
||||
|
||||
func _on_pick_up_detection_body_entered(body):
|
||||
|
||||
if body.pickupType == "stamina":
|
||||
pickupmsg = pickup_announce.instantiate()
|
||||
pickupmsg.pickuptext = "stamina"
|
||||
|
||||
Reference in New Issue
Block a user