Hi everyone. Right now I'm not with my pc around, so as soon as I can I'll update here with some code if needed.
Let me explain what is my game about and why what's my logic problem:
The race in my game takes place with 10 car entities, 9 are purely AI and 1 is an AI that occasionally the player may interfere with it's behavior. So basically all of them follow a path2d with a pathfollow2d in it, while avoiding each other and other obstacles.
How I have set up my initial race position, I retrieve the following variables:
Path2d size, each car position in the path, and lap count. The lap should be incremented by 1 once the first car pass through its checkpoint (The code for this is pretty easy, I just don't have a car for that lol)
So my main problem is, how should I approach this? I mean, what's the program logic I should use here? I'm thinking it like this:
Have a variable for each of their position minus the path size, so the greater the value, the further behind you are. Sort this out, but I should also check for lap count, if a car is on lap 2 it should not Sort the same as a car on lap 1 for example.
Even if I Sort their values in an array for instance, how am I supposed to know which is which after the array is sorted?
BTW I'm adding a label above each car so they can show their position real time.
The path2d size and position approach is perfect for me, and I think it's a much better solution than checkpoints, I really just need to sort this sorting problem lol.
Thanks in advance! If more info or code are needed please don't hesitate to ask me!