Object Train Algorithm

I have two snake objects - a head and a body. Each mesh has two more child objects at the beginning and at the end (A,B points). Point C - is the center of the object. Points B,C and B1,C1 are located in the same coordinates. The body looks at the head >
When I press the “W” button the head goes forward and I need to close the distance from the body mesh. I know the coordinates of all points and distances D and D1. How can I shift
my body mesh by distance D2 so that A1 is at point B? At the same time using vectors.

snakeBody[0].lookAt(snake.snakeHead.getWorldPosDots()[1]);

Lerp
https://threejs.org/docs/?q=vec#api/en/math/Vector3.lerpVectors
or chain physics

for lerp you can do a moveto type of function pos = lerp(pos, target, speed)

1 Like