From cc58b66cdd7d02ac2d9acccc5ea9fce99b850341 Mon Sep 17 00:00:00 2001 From: Zakarya Date: Thu, 11 Jan 2024 15:01:53 -0800 Subject: [PATCH] Add initial head rotation (fix for issue #5) --- addons/fpc/character.gd | 6 ++++++ addons/fpc/character.tscn | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/fpc/character.gd b/addons/fpc/character.gd index 2138cd8..1cc1c97 100644 --- a/addons/fpc/character.gd +++ b/addons/fpc/character.gd @@ -11,6 +11,8 @@ extends CharacterBody3D @export var jump_velocity : float = 4.5 @export var mouse_sensitivity : float = 0.1 +@export var initial_facing_direction : Vector3 = Vector3.ZERO + @export_group("Nodes") @export var HEAD : Node3D @export var CAMERA : Camera3D @@ -60,6 +62,10 @@ var gravity : float = ProjectSettings.get_setting("physics/3d/default_gravity") func _ready(): Input.mouse_mode = Input.MOUSE_MODE_CAPTURED + # Set the camera rotation to whatever initial_facing_direction is + if initial_facing_direction: + HEAD.set_rotation_degrees(initial_facing_direction) # I don't want to be calling this function if the vector is zero + # Reset the camera position CAMERA_ANIMATION.play("RESET") diff --git a/addons/fpc/character.tscn b/addons/fpc/character.tscn index 41f693a..ec29731 100644 --- a/addons/fpc/character.tscn +++ b/addons/fpc/character.tscn @@ -123,7 +123,6 @@ shape = SubResource("CapsuleShape3D_uy03j") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0) [node name="Camera" type="Camera3D" parent="Head"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) [node name="camera_animation" type="AnimationPlayer" parent="Head"] libraries = {