Files
fps_project_1/scripts/JumpPlatform.gd

35 lines
800 B
GDScript

extends Node3D
@export var jump_amount = 20
@export var stamina_replenish = true
@export var ammo_amount = 20
@onready var jump_sound = $JumpSound
var can_jump = false
var player
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if can_jump:
if Input.is_action_just_pressed("jump"):
player.velocity.y = jump_amount
jump_sound.play()
func _on_area_3d_body_entered(body):
if body.is_in_group("player"):
can_jump = true
player = body
if body.is_class("Chest"):
body.velocity.y = jump_amount
jump_sound.play()
func _on_area_3d_body_exited(body: Node3D) -> void:
if body.is_in_group("player"):
can_jump = false