32 lines
726 B
GDScript
32 lines
726 B
GDScript
extends StaticBody3D
|
|
|
|
@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
|
|
|
|
func _on_area_3d_body_exited(body: Node3D) -> void:
|
|
if body.is_in_group("player"):
|
|
can_jump = false
|