Smoothen camera

This commit is contained in:
Spencer Killen 2024-05-25 12:07:16 -06:00
parent 6766c63abe
commit 3eb8b2a718
Signed by: sjkillen
GPG Key ID: 3AF3117BA6FBB75B
2 changed files with 25 additions and 1 deletions

View File

@ -1,6 +1,9 @@
extends Node3D extends Node3D
const MOUSE_SENSITIVITY := .001 const MOUSE_SENSITIVITY := .001
const MOUSE_VISCOSITY := 0.5
var _goal_rotation_y := rotation.y
func get_input_direction() -> Vector2: func get_input_direction() -> Vector2:
var input := Input.get_vector("move_left", "move_right", "move_up", "move_down") var input := Input.get_vector("move_left", "move_right", "move_up", "move_down")
@ -15,6 +18,9 @@ func _process(_delta):
get_parent().movement_dir = get_input_direction() get_parent().movement_dir = get_input_direction()
%SpringArm3D.look_at(global_position) %SpringArm3D.look_at(global_position)
var rot_y := lerp_angle(rotation.y, _goal_rotation_y, MOUSE_VISCOSITY)
rotation.y = rot_y
func _ready(): func _ready():
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
@ -22,7 +28,7 @@ func handle_camera_movement(move: Vector2):
if Input.mouse_mode != Input.MOUSE_MODE_CAPTURED: if Input.mouse_mode != Input.MOUSE_MODE_CAPTURED:
return return
move *= MOUSE_SENSITIVITY move *= MOUSE_SENSITIVITY
rotate_y(-move.x) _goal_rotation_y -= move.x
func _input(event): func _input(event):
if event is InputEventMouseMotion: if event is InputEventMouseMotion:

View File

@ -8,6 +8,24 @@
config_version=5 config_version=5
[Fmod]
General/auto_initialize=true
General/channel_count=1024
General/is_live_update_enabled=true
General/is_memory_tracking_enabled=false
"Software Format/sample_rate"=48000
"Software Format/speaker_mode"=3
"Software Format/raw_speaker_count"=0
General/default_listener_count=1
General/banks_path="res://"
General/should_load_by_name=false
DSP/dsp_buffer_size=512
DSP/dsp_buffer_count=4
"3D Settings/doppler_scale"=1.0
"3D Settings/distance_factor"=1.0
"3D Settings/rolloff_scale"=1.0
[application] [application]
config/name="Grounders" config/name="Grounders"