I am working at a 2D Snake Game in Unity. This is the head of the Snake: https://i.sstatic.net/MeelN.png And this is the Extension of the tail of the snake. It is added everytime I eat something: https://i.sstatic.net/IoagT.png I made the head of the snake to move, but my question is how do I move the extensions? I tried to add these extensions as childs to the head , but when i rotate the head, it rotates the all extensions at the same time, but I want to rotate one extension at a time like a chain. I am using a C# Script
if (position == 1 || position == 3) {
if (Input.GetKey (KeyCode.UpArrow)) {
position = 2;
rotation=90;
transform.rotation=Quaternion.Euler(0,0,rotation);
} else if (Input.GetKey (KeyCode.DownArrow)) {
position = 4;
rotation=270;
transform.rotation=Quaternion.Euler (0,0,rotation);
}
} else if (position == 2 || position == 4) {
if(Input.GetKey(KeyCode.RightArrow)){
position=1;
rotation=0;
transform.rotation=Quaternion.Euler (0,0,rotation);
}
else if(Input.GetKey(KeyCode.LeftArrow)){
position=3;
rotation=180;
transform.rotation=Quaternion.Euler (0,0,rotation);
}
}
if (position == 1)
transform.Translate (Vector3.right * movementSpeed * Time.deltaTime,Space.World);
else if (position == 2)
transform.Translate (Vector3.up* movementSpeed * Time.deltaTime,Space.World);
else if(position==3)
transform.Translate(Vector3.left*movementSpeed*Time.deltaTime,Space.World);
else if(position==4)
transform.Translate (Vector3.down*movementSpeed*Time.deltaTime,Space.World);
int i;
for (i=1; i<extensions.Count; i++) {
extensions[i].transform.position=extensions[i-1].transform.position;
extensions[i].transform.rotation=extensions[i-1].transform.rotation;
}