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:
- The body moves with a speed that is set in the head script.
- 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.
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.