Algorithm to swim like a fish in c#

1.2k Views Asked by At

I need to implement a feature in my application where these words are going to "swim" around in the background, basically I need to pick a point in front of the leading letter of the word, and swim to it using a "wavey" style.

I also need to avoid the walls, so it turns in time, among other 'fish like' behaviors it needs to implement.

I'm sure I need to do something with a sin calculation, but I really want it to be efficient, I'm using C#, but any language implementation will be insightful.

What resources are out there for implementing this in C#?

2

There are 2 best solutions below

1
Jimmy On

one classic flocking simulation you could take a look at would be Boids

0
dkackman On

I've done something vaguely similar, where a series of letters animates based on the movement of the leading letter. It is mouse trailing, and not so much fish swimming, but the approach could be made to work as the positional offset decays as a function of the distance from the leading character.

It's MFC/C++ and is located on codeproject.