This is probably best described by image:
I have a character. For floor collision, it uses a single point (the red X). When the character moves, it conforms to the terrain; note how the blue line (its movment per frame) is the same length regardless of the slope.
I have the top three situations working fine. The issue is the bottom one, where the character is crossing over a change in slope. I handle the single-slope case just by rotating the impending movement vector, but obviously that won't work here.
My first instinct was to do something like this:
- Measure length to next vertex along first slope.
- Subtract length from impending movement vector.
- Position impending movement vector at vertex; rotate to match second slope and get resulting position.
- Put character at result position.
The problem is that it doesn't seem like this will chain very well if the character has to cross over three or more segments at once (maybe it's moving very fast over round-like terrain).
So basically at this point I'm looking to see if there's an easier solution I'm missing.