#Player-Model makes little "jumps" when camera follows it around

3 messages · Page 1 of 1 (latest)

coarse torrent
#

Set my Camera to follow an exported variable, which is set to the player node and the player makes little "jumps" when slowing down (velocity of player is lerped), see the video. Here's also the camera code:

class_name CameraIsometric extends Node3D

signal camera_isometric_rotated(rotation: float)

const DEFAULT_ROTATION: float = -45

## The IsometricCamera will follow the target, optional
@export var follow_target : Node3D = null
@export_range(0, 1) var camera_sensitivity: float = 0.25

@onready var input_events: InputEventsComponent = $InputEventsComponent

var mouse_movement: Vector2 = Vector2.ZERO


func _input(event: InputEvent) -> void:
    if input_events.is_camera_reset_pressed():
            rotation.y = DEFAULT_ROTATION
            
    if event is InputEventMouseMotion:
        mouse_movement = event.relative.normalized()


func _ready() -> void:
    # Signal should be emitted after all other nodes in the tree are ready,
    # so they can listen
    await owner.ready
    # ToDo **PLACEHOLDER**
    #SignalBus.emit_camera_rotation_changed(rotation_degrees.y)


func _process(delta: float) -> void:
    if input_events.is_camera_rotation_pressed():
        Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
        if abs(mouse_movement.x) > 0.1:
            var yaw: float = mouse_movement.x * camera_sensitivity
            rotate_y(deg_to_rad(-yaw))
    else:
        Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)


func _physics_process(delta: float) -> void:
    if follow_target:
        position = follow_target.global_position

Edit: attached video more than once. fixed

crude sonnet
#

I mean such jumps are normal when you use physics process to update visuals. A physics process step and a frame rendered in process are not the same and do not align. Physics runs up to 8 iterations in a loop depending on time but it also might not run at all in that frame. If you want smooth visuals you need to update all your visual assets in process, not in physics process. So update your follow position in process and not in physics process.

coarse torrent
#

I used to do it in _physics_process in other projects and it worked fine there... really strange