My problem is that I have a characterBody 2D, and I want it to move following my vector2 coordinates. However, during the movement process, I noticed that it experiences jittering in all directions.
I've read many articles related to issues with Camera2D, but I'm not using a camera.
Currently, I've tried:
- Limiting the FPS to 60.
- Moving the code from _PhysicsProcess to _Process.
- Adding delta.
None of these changes have resolved the jittering issue.
The jittering issue is particularly noticeable when the target is set to new Vector2(0,100), but it's not very apparent when the target is set to new Vector2(100,100).
This is the record
My sprite2d texture is using the default icon.svg
Below is my code
public override void _PhysicsProcess(float delta)
{
var targetPosition = new Vector2(0,100);
fsm.NPCNode.Velocity = fsm.NPCNode.Position.DirectionTo(targetPosition) * speed;
if (fsm.NPCNode.Position.DistanceTo(targetPosition) > 5)
{
fsm.NPCNode.MoveAndSlide();
}
}