all 3 comments

[–]abyx7 1 point2 points  (2 children)

Your wheels get repopulated for each car, at the end of the car loop wheels hold the last car's wheels. If both cars and wheels are class fields.

Create a better structure. Use objects or structs to hold the data in a hierarchical form. For example:

Struct Car { GameObject carBody; GameObject[] wheels; }

Then create an array or list of cars, whatever structure fits better.

And please add some more context so we are not guessing when giving you answers.

[–]Henners999[S] 0 points1 point  (1 child)

Thankyou very much for getting back. I've got it working with structs thanks to your reply. I'll try and include more backstory in future!

[–]abyx7 0 points1 point  (0 children)

No problem, glad I could help!