Perfecting Laning System

So so close to a perfect laning system!

In the previous iteration of the laning system, I had eliminated the jittery movement but introduced a “drift” effect – when the player rotates “early” or “late” (aka at the edges of a tile) into two tiles, the collision would anchor the player creating a fast and furious style drift around a turn. Visualized here:

This morning (while watching the GSL Code S Finals, hype!) I figured out a way to eliminate almost every case where the drift occurs. My approach was two-fold:

  1. Instead of an instant rotation with transform.Rotate(new Vector3(0, 90, 0)); I wrote a Lerp coroutine to rotate 90 degrees over a very small amount of time (available here).
  2. Instead of anchoring the player as soon as they rotated, I wait until the Linear Interpolation in #1 is finished, then anchor the player in whatever Tile they are now in.

The results are almost perfect. You’ll notice a single “almost-drift” at the beginning of this GIF, which I’m not sure if I can prevent (WIP) but is completely drift-free:

One thought on “Perfecting Laning System

Leave a Reply

Your email address will not be published. Required fields are marked *