0
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ 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. ;) \$\endgroup\$ – DMGregory Mar 29 '17 at 19:18
  • \$\begingroup\$ google.ro/… \$\endgroup\$ – Andrew Stef Mar 29 '17 at 19:45
  • \$\begingroup\$ Imagine that the object does this by itself \$\endgroup\$ – Andrew Stef Mar 29 '17 at 19:45
1
\$\begingroup\$

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

This is the result of Rusildo's answer::

enter image description here

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Gnemlock Mar 30 '17 at 6:53
  • \$\begingroup\$ @Gnemlock got it! \$\endgroup\$ – Bartosh Polonski Apr 8 '17 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.