Tutorial finished
This commit is contained in:
14
Player.gd
14
Player.gd
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user