Camera is shaking

Godot Version

Question

i made a thing that if the player touches an area a character body in daid area would go to that point to the one where the “target” is. their function is to be some type of camera where it smoothly goes to the point where the "target is centered. the thing is that when the character body arrives at theis locartion the screen starts shaking, i tried to take of the collisio of the characte which they have to focus but its still shakes. Why?


We don’t know why.

We cannot read your mind or know what your project is like. We don’t know what code you wrote, or what your node structure looks like.

Please see: Posting guidelines in #Help channel

charater body that goes to the "target

extends CharacterBody2D
@onready var target = $“../CharacterBody2D”
var Speed = 0

func _physics_process(delta: float) → void:
var direction=(target.position-position).normalized()
velocity=direction * Speed
look_at(target.position)
move_and_slide()

code at the node2d where it determinates the player camera will be disabled and set the “cameramen” speed to 900 so they arrives at the target

func _on_area_2d_2_body_entered(body: Node2D) → void:
if body.is_in_group(“player”):
$Node2D/Player/Camera2D.enabled = false
$CharacterBody2D2/Camera2D.enabled = true
$CharacterBody2D2.Speed = 900

code inside the area2d inside the character that is the point b where the speed is set back to 0 so they would stand still

func _process(delta: float) → void:
pass

func _on_body_entered(body: Node2D) → void:
if body.is_in_group(“cameramen”):
$“../../CharacterBody2D2”.Speed = 0

that’s all the code i made

Please format your code properly as per the instructions of the post I provided.

like this?
[quote="Claude_Slowness, post:3, topic:143809, full:true"]
charater body that goes to the "target

extends CharacterBody2D
@onready var target = $“../CharacterBody2D”
var Speed = 0

func \_physics_process(delta: float) → void:
var direction=(target.position-position).normalized()
velocity=direction \* Speed
look_at(target.position)
move_and_slide()

code at the node2d where it determinates the player camera will be disabled and set the “cameramen” speed to 900 so they arrives at the target

func \_on_area_2d_2_body_entered(body: Node2D) → void:
if body.is_in_group(“player”):
$Node2D/Player/Camera2D.enabled = false
$CharacterBody2D2/Camera2D.enabled = true
$CharacterBody2D2.Speed = 900

code inside the area2d inside the character that is the point b where the speed is set back to 0 so they would stand still

func \_process(delta: float) → void:
pass

func \_on_body_entered(body: Node2D) → void:
if body.is_in_group(“cameramen”):
$“../../CharacterBody2D2”.Speed = 0

that’s all the code i made
[/quote]


okay so im going to redo the toic but whit the coloured code( i forgot how to do this at the replies)

Please do not duplicate topics. You can edit your posts.

The problem should be that youur camera moves towards the player by velocity=direction * Speed amount. If the player is e.g. 20 pixels to the left and you move the camera by 30, then you will appear 10 pixels on the other side, and again jump back to 20 pixels to the right of the target.

You should do something like position = position.move_toward(target.global_position, Speed * delta)

@Claude_Slowness please don’t duplicate the posts, as @tibaverus mentioned - you can simply edit your original posts.
And please check Posting guidelines in #Help channel, there are instructions how to properly format your code to be readable.