I’m trying to make a text box display the value of it’s parent objects stats. The text box is attached to a sprite which has an attached script which tracks the stats of the sprite such as HP, damage, etc.
I created a standard singleton (as shown here) in the stat tracking script and reference it in the text box script to show the value of the sprite. This part works fine. However, when I create another sprite from the same prefab, both text boxes show the same value instead of only showing the value of its parent.
So if I have two sprites, one with 10 hp and one with 20 hp, both text boxes show 10hp or 20hp, when one should show 10 and one should show 20. How do I set the text box to only show the value of its parent? Can I still use a singleton for this or do I need another method?
I should also add that I’ve tried doing this without singletons and so far without any success.