Hello all, I’m trying to figure out the logic for what I should do. I’m making a fruit ninja clone as a practice project (fruit ninja is a game where a player controls a blade and cuts fruit for points). I want different fruit to give different points based on which ones are cut. I originally did it based on name of each fruit prefab instantiated into the scene (see attached image). My colleague helped me realize that programming it like this isn’t optimal since more fruit added will make the code too long and easier to have bugs if a designer changes the name of the fruit. Adding a different tag for each fruit would also be way too many tags depending on how many fruit are added.
I want to make more optimal code so I thought using scriptable objects might be a good idea since they hold data and are easy for designers to access in the inspector. I made a scriptable object script that lets each scriptable object hold a score/point multiplier (float), a fruit prefab (prefab), and a spawn rate to be implemented later (float). I’m having trouble figuring out how to get the player blade to read a spawned scriptable object or prefab through collision and correctly read the score multiplier on the scriptable object. Is this an incorrect use of scriptable objects? Is there a different way to get different points on sliced fruit through collision? Let me know if I need to add more details to this post to better ask my question as well (I could improve on forum-asking skills as well). Thank you so much for your time!