Im currently learning Unity3D and I would like to recreate the old Nokia game "Snakes" (example video: https://www.youtube.com/watch?v=FXg3jVG-tXs&ab_channel=aantv, play it at 1:30 and notice the movement and even the animations when the snake is turning to the sides).
The game movement is grid based as you can see, so the snake can turn only, when the head is in the center of each floor slab. I have done this by using Coroutine and I am interpolating the position of the head between the distance of each 2 slabs. (example video: https://www.youtube.com/watch?v=_LWYQE1UC68&ab_channel=Chlebikpastika).
My question is, how to design and implement the solution using procedural mesh? My idea is to update the vertices of corresponding snake body part with the values of vertices of previous snake body part. I could have Body class, which could have the buffer of vertex positions of previous body, and after each update, the vertices would be updated with currently poped values from buffer. I dont know if this is good design, do you have any ideas how I could achieve the movement of vertices of the snake?
i
then incrementi
by 1. Keep repeating for new segments. Ifi > array length
, seti = 0
. When you want to get current snake body positions, make a note of i then decrease by 1 and you have the neck location. Subtract 1 again and it's the next segment. Keep doing until you've reached the array length. Obviously ifi < 0
, seti = length -1
. \$\endgroup\$