Tutorial finished

This commit is contained in:
2024-06-12 11:54:41 +02:00
parent 7b760c3ba8
commit 9cfd9e0200
9 changed files with 258 additions and 6 deletions

View File

@@ -5,6 +5,8 @@ extends CharacterBody3D
@export var jump_impulse = 20 # m/s
@export var bounce_impulse = 16 # m/s
signal hit
var target_velocity = Vector3.ZERO
func _physics_process(delta):
@@ -25,6 +27,11 @@ func _physics_process(delta):
if direction != Vector3.ZERO:
direction = direction.normalized()
$Pivot.basis = Basis.looking_at(direction)
$AnimationPlayer.speed_scale = 4
else:
$AnimationPlayer.speed_scale = 1
$Pivot.rotation.x = PI / 6 * velocity.y / jump_impulse
# Ground velocity
target_velocity.x = direction.x * speed
@@ -54,3 +61,10 @@ func _physics_process(delta):
# Move the character
velocity = target_velocity
move_and_slide()
func die():
hit.emit()
queue_free()
func _on_mob_detector_body_entered(body):
die()