Sunday, March 9, 2014

Wandering Steering Behavior and Track Generation

If you've been following the development of my thesis project at all, you'll know that Vinyl generates its levels from the music you load into it.  Therefore all the bumps match the waveform of the song itself.  Aside from that, we just had the whole thing spiral inward to represent being in the groove of a vinyl record.

It turns out however, that constantly turning left is boring, so we decided to make the path turn randomly in any direction.

To tackle making a path that seems to wander I started with a steering behavior shown to me in an engineering class.  Upon trying a few times to implement this I ran into a few problems.  The main one being that the track could potentially wander back onto itself.  That could be remedied with a few safety checks, but I wanted more control over certain aspects of the tracks generation.

What we ended up doing was creating a "player" struct that just consisted on a position vector and a rotation and moved it forward in space one unit at a time.  Each step would rotate the vector by its rotation and add it to the previous position.  After it was complete, we had a spline of data representing the track and adjusted it's y values according to the waveform of the song.  From there we could use the same mesh generation code we were using to create the track when it was a spiral.

To further refine this process, we would randomly pick a direction to rotate in and decide how sharp of a turn to make.  After going far enough in a certain direction I'd make sure to prevent the track from looping onto itself.  With a few more checks and random elements thrown in, we were able to create much more fun and compelling tracks all procedurally generated.

Check 'em out in our Let's Play!


No comments:

Post a Comment