- Home /
How To Make a Snake-like Movement without Food ? [UNITY 2D]
I'm new to Unity and wonder how to make snake-like movement but its tail is in certain amount every level, for example in level 1 snake lenght is 5 but then in level 2 its length is 6. In the long run i want to make cable like movement or rope. I inspired by snakebird and couldn't find tutorial that has same approach as this game has.
I'm very grateful for your answers and I'm very sorry for my english. Thanks
Answer by TomArano_Dimenco · Jan 21, 2020 at 01:54 PM
thinking out loud a bit
basically every segment of the snake follows the head but than delayed, i would keep a list of "previous positions" and shift that list every time you move (new head pos wil be list[0] and old head pos wil be list[1], etc etc etc) make your list as long as the snake will be and put segments on every position of the list.
Falling like the snake does in Snakebird will than also be easy as you just change very segment in the list by the same amount when it should fall.
Above idea is assuming that the snake will use a tile system and will not move freely (in which case u will need physics), Good luck
Your answer
Follow this Question
Related Questions
How do i make a cube move (Continuosly without stopping) when i press a button once in unity 2D 2 Answers
How to smooth out character Roll in a Top-down 2D movement 0 Answers
Unity 2D - Use Digital Painting as Terrain 1 Answer
Aceleration 2D 0 Answers
Why does this piece of code work with gravity and this one dosent 2 Answers