Worm/Snake movement with segments

I wanna make a snake/worm that is made out of 4 segments and moves like a snake/worm to a target position I tried using ballsocketconstraints and rope constraints but it does not seem “Snake/Worm” Like it my idea maybe I could script it to work like that but I am not really sure how

update: I also tried using Inverse kinematics but the physics are weird

And the segments need to have collision btw