Godot Version
Godot 4.3 stable
Question
I’m having problems with physics interpolation. Despite turning it on in settings I still see obvious jittering when the player is moving and there is no difference when I switch it on or off.
The I only good fix I have found is increasing the physics tick rate from 60 to 144 and capping the fps at 144, but I have a feeling this isn’t optimal.
Here’s my movement/camera code:
extends CharacterBody3D
@export var SPEED = 5
@export var JUMP_VELOCITY = 4.5
@export var SENS = 0.1
@export var HEAD : Node3D
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
rotate_y(deg_to_rad(-event.relative.x * SENS))
HEAD.rotate_x(deg_to_rad(-event.relative.y * SENS))
HEAD.rotation.x = clamp(HEAD.rotation.x, -90, 88)
if event.is_action_pressed("exit"):
get_tree().quit()
func _ready():
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
#Engine.max_fps = 30
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("move_left", "move_right", "move_forward", "move_back")
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
move_and_slide()