I am not sure how to approach this. I have a given gameobject called collectible.go, which always behaves the same way: when the player touches it, it disappears and adds its value to the player’s score. So this collectible.go has a collisionobject, a collectible.script and a sprite. The sprite is my concern.
This collectible can look different and have different values depending on its nature: a coin, a diamond, a gold nugget. Thing is, I can’t just add some Game Object files to the level collection and change their sprite, because… all of them change!
How can I reuse the same game object? Because creating a game object for each collectible, given they behave exactly the same, doesn’t seem too sensible…
The only solution I’ve come up with is setting the sprite and the atlas (and the score value) in the collectible.script as properties, so I can configure them in the editor, and then change their sprite in runtime - it works if I do it in runtime. But that makes level design a bit more cumbersome…
When you say “different sprites”, do you mean the flipbook animation?
For instance, when spawning a game object from a factory, you can set the animation when spawning.
(I’m assuming they all use the same .atlas, as that will reduce the number of draw calls)
Although I now realise that with the go.property() you get the ability to change the value in the editor, which is probably what @playmedusa wants! So what @JCash suggests is a good solution!