# Wave formula(s) (math)

Hey, i am making a game where you control a ship on a rough ocean and have to fight the waves and other ships.

I have the wave “simulation” working fine, that is using overlapping sinus waves. However, pure sinus waves looks a bit dull, and i was wondering if anyone knows any other mathematical approaches for creating “sinus-like” waves? Maybe some with a sharper top than a sinus wave, and some tilting forward like waves that are about to collapse.

Also, as it currently stands waves have a center and moves in one specific direction. I would like the ability to create a wave which moves out from a center, like when you throw a rock into water in real life. Do anyone know how to do this?

Triangle wave may be your solution:

but when you will see the equation, I guess you will be happy with your sin wave.

Other solution is just to move left to right and downward:

``````float maxLeft, maxRight;
bool direction = true;

void Update()
{
Vector3 pos = transform.position;
pos.y -= speed *Time.deltaTime;
if(direction)
{
pos.x += speed *Time.deltaTime;
if(pos.x >= maxRight)direction = false;
}
else
{
pos.x -= speed *Time.deltaTime;
if(pos.x <= maxLeft)direction = true;
}
}
``````

You could use some more technical way with MoveTowards and placing game objects to mark the target points but this one above is understandable.