Waypoint System For Rail Shooter

Im making a rail shooter so i wanted a fairly simple waypoint system for the playerpawn to follow. After a day of tinkering i found a solution, but it feels…silly.

My first solution was to use the playerblueprint and get all actors of class, and then add 1 to the actor found in the array when i hit the waypoint, so it would change to the next waypoint, however, there was no guarantee the ‘get all actors of class’ would find them in a specific order.

So i tried making an array in the level blueprint which would allow me to assign each waypoint a number, then when i collided with waypoint i could add 1 to a variable and it would find the next waypoint in the array for me…However i could not find a way to call or get that array from the level blueprint(which is where it has to be created, i believe).

I guess what im asking is if someone might have a more elegant solution to what i have now which seems clunky.(maybe its just me?)

on your waypoint objects, you can add an actor tag, and inside the pawn/character, you can check for the overlap event, and verify that it has the tag you set up. if it has the right tag, cast it to a waypoint actor, and copy its spawn location to the player. copying a vector would be better than updating a reference object, because you can save a vector in a save file, while references cannot be saved, and will become invalid eventually.

its usually a bad idea to let the environment change the players state in the level blueprint, you should let the player change their own state when they interact with the environment, in a generic way. ideally, you want level designers to be able to place waypoint actors without coding anything, and if you expose the spawn location vector, they won’t ever need to open the waypoints blueprint.

actor tag reference:
https://answers.unrealengine.com/questions/24582/how-to-tag-playerenemybullet.html