# Help with a snake like movement

I am looking for an algorithm that moves an object at a regular speed in a snake-circular like movement. This movement should look pseudo-random and smooth, later on I am going to add other body parts, but so far this is the essential.

My try so far has consisted in having a random value t that chages each frame:

t= Random.Range(t-20f,t+20f);

and according to it I was employing a direction. The result should be more directions that are smoothly different, so that the movement itself is smooth.

I would score the solution with 7/10, and moreover, it doesn't describe like short circles, but rather larger ones and the negative result is that the object exits the scene quite fast.

What is your algorithm solution? On the internet I found solutions where the player moves the head of the snake, but here the object acts like an autonomous object.

• It's not entirely clear to me what kind of movement you want. Are you able to include or link to an animated example, or perhaps a diagram showing a desirable sequence of movement states? Geometry problems almost always benefit from visual examples. ;) Mar 29 '17 at 19:18
• google.ro/… Mar 29 '17 at 19:45
• Imagine that the object does this by itself Mar 29 '17 at 19:45

I would recommend using the wander algorithm. You can find a code sample here and here.

This is the result of Rusildo's answer::

• Please note that you still need to give credit to other people when you copy their content, especially if they have posted their content for another question, in which your answer is just a redirect. Mar 30 '17 at 6:53
• @Gnemlock got it! Apr 8 '17 at 19:50