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\$
3
  • 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
    Commented Mar 29, 2017 at 19:18
  • \$\begingroup\$ google.ro/… \$\endgroup\$ Commented Mar 29, 2017 at 19:45
  • \$\begingroup\$ Imagine that the object does this by itself \$\endgroup\$ Commented Mar 29, 2017 at 19:45

1 Answer 1

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\$
2
  • \$\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
    Commented Mar 30, 2017 at 6:53
  • \$\begingroup\$ @Gnemlock got it! \$\endgroup\$ Commented Apr 8, 2017 at 19:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .