Skip to content

Commit

Permalink
moved camera movement into physic_process
Browse files Browse the repository at this point in the history
  • Loading branch information
ninetailsrabbit committed Dec 27, 2024
1 parent 04ad3f7 commit eaf8083
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class_name CameraController3D extends Node3D
set(value):
if value != swing_head_enabled:
swing_head_enabled = value
set_physics_process(swing_head_enabled or (bob_enabled and bob_head != null))

@export_range(0, 360.0, 0.01) var swing_rotation_degrees = 1.5
@export var swing_lerp_factor = 5.0
Expand All @@ -22,7 +21,6 @@ class_name CameraController3D extends Node3D
set(value):
if value != bob_enabled:
bob_enabled = value
set_physics_process(swing_head_enabled or (bob_enabled and bob_head != null))

@export var bob_head: Node3D:
set(value):
Expand Down Expand Up @@ -61,11 +59,10 @@ func _unhandled_input(event: InputEvent) -> void:
var motion: InputEventMouseMotion = event.xformed_by(get_tree().root.get_final_transform())
last_mouse_input = motion.relative


func _ready() -> void:
assert(actor is Node3D, "CameraController: actor Node3D is not set, this camera controller needs a reference to apply the camera movement")

set_physics_process(swing_head_enabled or (bob_enabled and bob_head != null))

current_horizontal_limit = camera_horizontal_limit
current_vertical_limit = camera_vertical_limit
Expand All @@ -82,12 +79,9 @@ func _ready() -> void:
func _physics_process(delta: float) -> void:
swing_head(delta)
headbob(delta)
rotate_camera(last_mouse_input)


func _process(_delta: float) -> void:
rotate_camera(last_mouse_input)


func rotate_camera(motion: Vector2) -> void:
var mouse_sens: float = mouse_sensitivity / 1000 # radians/pixel, 3 becomes 0.003

Expand Down
17 changes: 0 additions & 17 deletions components/motion/3D/first_person_test.gd

This file was deleted.

25 changes: 0 additions & 25 deletions components/motion/3D/first_person_test.tscn

This file was deleted.

0 comments on commit eaf8083

Please sign in to comment.