It was, I was already trying to figure out my question by asking a question like this, which would not reveal all the cards. This venture failed because I ask the second question.
I write a snake on a unit. The snake consists of three game objects: the head, the body (which should then be duplicated) and the tail. The head is given the speed of movement and control of the arrows, the body must follow the route of the head completely. The idea was:

  1. The body moves with a speed that is set in the head script.
  2. If the rotation key is pressed (the head simply rotates), the body enters into four different queues: in x, y — the coordinates of the rotation, in rz, rw — the rotation parameters for which the head is turned.
  3. If the position of the body coincides with the top element of the queue, then

    body.transform.rotation.set(body.transform.rotation.x, body.transform.rotation.y, rz.pop(), rw.pop()); 

The corresponding rotation is set and these coordinates are forgotten.
In fact, this is all wonderful and beautiful, however, the body goes stupidly in a straight line, despite the fact that all the necessary coordinates are entered in the queue.

    2 answers 2

    Wasn't it easier to make a move from the tail? In a classic snake, the body consists of equal nodes. We run from the tail to the head and rearrange the node n into the place in front of it, and turn it around just as the previous node n-1 was rotated. When we go through all the nodes and get to the head, it remains only to direct the head in the direction that the user moves the snake. After that, you may have to turn the next node in the desired direction, and in general, that's all. And do not need any queue)

    • Great! Thank! - Nicolas Chabanovsky

    Problem solved. The bottom line was that the body jumped the necessary coordinates