so i’m working on a racing Game in which you Race against AI’s.
Every car in the game (incl. the players one) has a carEngine script attached to it, which for example makes the car accelerate as soon as the race starts.
Also the carEngine script has a piece of code measuring the time it took a car to get from start to finish Line.
Obviously when finishing the race i want to display a table with your own and your rivals (AI’s) racetimes.
The thing is, these AI’s are all identical Clones (instantiated from a Prefab when the race begins) with identical carEngine scripts.
Now the question… whats the best way to access, collect and store all these Individual racetimes from these AI Clones carEngine scripts?
I intentionally did not include any code snippets as I’m not in need for a fitted solution but rather a general understanding on how to access and differentiate values of multiple Identical GameObjects.
I know, i could give all these AIs individual names when Instantiating them but that just doesn’t feel like the best/ most efficient way to do it Correct me on that if you think its fine.
Things I googled, that didn’t help me, mostly because everyone always asks for fitted solutions:
unity get value from ai
unity ai communications
unity access script of instantiated object clone
unity access script of instantiated object
unity referencing prefab clones
unity access script of specific clone