Move ball to render tick for smoothness

This commit is contained in:
Thomas Muller 2023-10-03 19:26:49 -04:00
parent 33ba20a9a1
commit 7b71894a16

View file

@ -34,6 +34,11 @@ func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _process(delta):
# Do this on the render tick so it doesnt jitter at higher FPS
_ball.global_position = _camera.global_position - _camera.global_transform.basis.z * 2.0
func _physics_process(delta):
# Shamelessly stolen code from quake :)
@ -89,8 +94,6 @@ func _physics_process(delta):
velocity = vel
move_and_slide()
_ball.global_position = _camera.global_position - _camera.global_transform.basis.z * 2.0
func _apply_friction(vel: Vector3, delta: float):
var speed = sqrt(vel.x ** 2 + vel.z ** 2)
if(speed == 0.0): return vel