Endless Runner - Changing Lanes on rotated tiles?

Hello, apologies if this isn’t the correct place to ask this.

Essentially I’m learning UE4 by making an endless runner, but I’ve run into an issue with my method of picking which “lane” to move to on a tile that has rotated. I’m hoping for better solutions / ideas for my terrible logic.

My basic logic is:

  • Tile has n number of arrows which dictate the “lanes” (n arrows because different tiles have a different number of available lanes)
  • On tile creation I populate an array with the location vectors of the arrows (lanes)
  • Once the player enters the tile, it sets the players current lane options to that array.
  • The player holds a copy of the current tile’s lane options along with an index of what lane the player is currently in and swaps between them by grabbing the Y location and adjusting the position accordingly.

This was working fine until I’ve added in the ability to turn a corner (always +90 or -90 degrees). The new problem is the Y doesn’t change if you’ve turned 90 degrees as now X is the value that turns left or right.

I’ve thought of picking either X or Y when changing lanes based on what the current rotation is, but overall it seems like a messy solution.

Anyone any ideas on a better solution for locking the player to lanes?

Interesting problem. First thing I might do is use the arrow’s world rotation and set it to the character. This should get your character facing in the same direction as the arrows on the tile. Also, there’s issues where if you add rotation you can be off by a fraction of a degree (0 degrees + 90 degrees ends up being 90.000000001 degrees or something). You may not notice it but over time it could theoretically add up, plus it makes the numbers messy. By setting the rotation you avoid the issue.

Ok, so now your character is facing the right direction and I’m assuming moving in the right direction (assuming you’re adding movement input relative to the character’s forward vector).

Now switching lanes based on the rotation of the tile … I think this could be solved by setting the player’s relative Y location based on the relative Y location of the tile, instead of using the world location. That should ensure that your character moves correctly on the tile regardless of the tile’s rotation in the world.

Relative position - exactly what I was looking for. That has made this a lot easier, thanks for the help!

Use Unreal Spline System, This IS Best!!!