Snaking - making body parts follow each other.

Hi all, I'm creating a top-down 2d snake-like game.

Basically, the player controls the head and has to go around collecting body parts.

I've already managed to get the body part to follow the head when it gets close enough. `if(Vector3.Distance(objPlayer.transform.position,transform.position)<2f) {

rigidbody.AddForce(inputMovement.normalizedmoveSpeedTime.deltaTime);

transform.position = new Vector3(transform.position.x, 0, transform.position.z);

}
`

But i don't know how to get other body parts to follow the collected body parts.

Basically i just need a starting point. If you could point me in the right direction, I could carry on from there.

Thanks in advance for your help. :)

A technique would be to apply the SmoothFollow script (it's one of the Unity's camera scripts) to the object that follows preceding body part. Head <- body part1 <- body part2 <- body part3, etc.

See: Tornadotwins tutorial #9

Having programmed this exact game years ago when the language for doing so was CBasic I can tell you that the most common way it was done was to create an array of body parts and reposition the “tail” to the new “head” at the time. This was possible because it was ASCII graphics and there was nothing more than just solid filled squared. Thus, you created the illusion of movement by only changing the position of one object.

Depending on how low-key your graphics are, you might be able to do something similar. Or anyone else who ends up seeing this answer for this problem, for that matter.

I've solved it.