I would like to know how can I find out which player leads a track, via a spline.
Any idea how to realize this? Best without any check points, but just marking where the track starts and where it ends, during this, the track may have curves and strange as well.
I was on IRC, and someone did recommend me to expose the function “GetInnacurateNearestPosition()” from c++ into Blueprints, I did this, but still I have no clue…
This here are a few ideas for such a function, for every time the number is higher than the number of the other player, he moves one place down. (to nr 1)
A naive approach in blueprints would be to generate a set of sample locations at fixed times along the spline, calculate the distance to each racer to each point to find their approximate time on the spline, and then sort by that. That would have a host of issues to work through such as figuring who is closer if both racers are closest to the same sample point on the spline. Theoretically GetInnacurateNearestPosition() should be a better approach than what I described, but conceivably there could still be edge cases that report incorrectly, especially if you had overlapping splines and whatnot.
Do I have to work with individual spline points, or the whole spline? I posted a screen of my current function. I tried to look for the values of both return value and out position squared, but its just like cordinates in the world map, its not bound to the spline, so its useless.
My solution is to reuse the part where TextComponents (which act as showing the number of the spline point slightly above the track) get spawned in the RoadGenerator blueprint, and instead of spawning textcomponents, I placed Spawn Actor nodes. Keep in mind that Spawn Actor from Class is not available in the construction script, so move them to Event Begin Play.
If you really want them in the construction script, make your own UFunction in a Blueprint Function Library.