since I’m still pretty new to Unity, I have another Question regarding best practice with handling prefabs.
Imagine your game had 10 different types of Cars, 10 different models and properties like speed, weight, and so on.
Would you rather create 10 Prefabs, one for each type of car, assigning each model and setting each property for every single car, or create one single Prefab “Car”, instanciate them at runtime and assign the models via code?
I have no Idea what the correct way of doing this could be.
A) If your car can swap more things than just art, then I would make the prefab like a shell of a car, then I build it up via code. Usually by further instantiating other prefabs as the parts. Then you can do stuff like pick the wheels, chassis, spoiler, or whatever else you want to attach. (You can even start doing things like attach different AIs, custom sound packs, etc.) The downside is this takes some more time. It might not be time efficient to split your prefabs into pieces and write more code.
B) If you only have 10 cars then I don’t see a problem with having 10 prefabs already all set up. This method is probably faster. It is also easier to see the entire car at once and work on it. If you start to “customize” the cars then I would go back to the method above and break the car up into parts.
If you have many different cars that vary slightly, you could leave some parts of it to code. For example you have 10 different base cars, and each level they spawn with 10 more health, and maybe move a little faster. It wouldn’t make sense to create a new prefab for this, but rather just bump up the health on creation via code.
This may also help when it comes to prefabs that vary slightly, but otherwise share the same components.