Snake like movement via Verlet Integration - inverted parts?

I’m creating a snake using verlet & bones

I’ve achieved a almost desired effect using @EgoMoose’s verlet module:

The example above was setting the WorldPosition of the bone to bones verlet point’s position - this worked okay-ish but as you can see when the snake turns each segment also turns on the y axis to the first segments orientation

I thought I could solve this by instead setting the bones WorldCFrame to “look at” the next points position, this worked pretty well as below:

However the parts are “inverted” quite literally, I’m not sure why this is happening at all - Here is the current place file if you wish to take a look! Snake Rig.rbxl (33.0 KB) To test you can enter play test mode as I’ve set the snake to be the StarterCharacter. The code for this is in StarterCharacterScripts and the Verlet module is in ReplicatedStorage

Any help or guidance would be much appreciated!

Link to where I got the Verlet Integration from: Help with Cape Simulation Physics - #5 by EgoMoose

6 Likes

I know this topic is very old and that you already figured it out (https://twitter.com/rWonuf/status/1435735685173026816), but still wanted to add a solution for people that stumble on this thread.

I tried the best way to debug any problem in programming: entering some semi-random values to see if that fixes it :sweat_smile:.

Anyways, rotating 180° along the z-axis fixes it: change line 42 to:

point[1].WorldCFrame = CFrame.new(point[2].Position, npoint[2].Position) * CFrame.Angles(math.rad(90), 0, math.rad(180))

Fixed placefile:
snake_fixed.rbxl (56.4 KB)