add format and comments

This commit is contained in:
2024-10-06 05:11:56 +10:00
parent dc7463722f
commit 78949b163d
2 changed files with 6 additions and 1 deletions

View File

@@ -81,6 +81,7 @@ func _notification(what: int) -> void:
window_out_of_focus = true window_out_of_focus = true
## Start gradually moving camera towards a position
func head_to(to: Vector3, zoom: float = ZOOM_VALUE_DEFAULT) -> void: func head_to(to: Vector3, zoom: float = ZOOM_VALUE_DEFAULT) -> void:
heading_to_position = to heading_to_position = to
heading_from_position = target_position heading_from_position = target_position

View File

@@ -73,7 +73,11 @@ func _animate(delta: float) -> void:
if velocity.length() > 0.1: if velocity.length() > 0.1:
var velocity_normalized := velocity.normalized() var velocity_normalized := velocity.normalized()
var angle := atan2(-velocity_normalized.x, -velocity_normalized.z) + PI var angle := atan2(-velocity_normalized.x, -velocity_normalized.z) + PI
global_rotation.y = rotate_toward(global_rotation.y, angle, TURN_SPEED * delta) global_rotation.y = rotate_toward(
global_rotation.y,
angle,
TURN_SPEED * delta,
)
# look_at(global_position + velocity, Vector3.UP, true) # look_at(global_position + velocity, Vector3.UP, true)
animation_player.play('walk') animation_player.play('walk')
else: else: