S
ScaryPotato
Guest
I'm working on a racing game, and have been trying to figure out a consistent way to display who's in 1st/2nd/3rd etc, and this is what I have right now.
There's a path running down the middle of the track, and on it, I've got an object moving along it (ahead of oNPC and oPlayer), and use point_distance to calculate which racer is closest to it. The idea works well enough for 3 racers, but think I can use an array to store the distance information.
My real question is this: Is there a way for oNPC and oPlayer to track where they are on that path, even though they're not moving along the path? It seems like it would be a much cleaner way of the tracking progress of each lap if it's possible to do.
Thanks in advance for any insight you have!
There's a path running down the middle of the track, and on it, I've got an object moving along it (ahead of oNPC and oPlayer), and use point_distance to calculate which racer is closest to it. The idea works well enough for 3 racers, but think I can use an array to store the distance information.
My real question is this: Is there a way for oNPC and oPlayer to track where they are on that path, even though they're not moving along the path? It seems like it would be a much cleaner way of the tracking progress of each lap if it's possible to do.
Thanks in advance for any insight you have!
GML:
var Nearest=instance_nearest(x, y, oNPC);
var Furthest=instance_furthest(x, y, oNPC);
var Middle=instance_nearest(Nearest.x, Nearest.y, oNPC);
var Player=oPlayer;
if (point_distance(x, y, Player.x, Player.y) < point_distance(x, y, Nearest.x, Nearest.y))
{draw_text(Player.x, Player.y-32, "1st");}
if ((point_distance(x, y, Player.x, Player.y) > point_distance(x, y, Nearest.x, Nearest.y)) && (point_distance(x, y, Player.x, Player.y) < point_distance(x, y, Middle.x, Middle.y)))
{draw_text(Player.x, Player.y-32, "2nd");}
if ((point_distance(x, y, Player.x, Player.y) > point_distance(x, y, Middle.x, Middle.y)) && (point_distance(x, y, Player.x, Player.y) < point_distance(x, y, Furthest.x, Furthest.y)))
{draw_text(Player.x, Player.y-32, "3rd");}
if (point_distance(x, y, Player.x, Player.y) > point_distance(x, y, Furthest.x, Furthest.y))
{draw_text(Player.x, Player.y-32, "4th");}