How to individually update Instantiated sliders

Hi, I just started learning unity 2d, so i ran into some issues.
i have a game where there are skeleton enemies which are Instantiated at the start of the game. i used a slider as a health bar for the enemy. But now i have no idea how to change the values of these slider separately.
for eg. if i spawn 3 enemies, each will have a have health bar( i.e. slider) above them. if i hit skeleton_1 the value of the health bar of skeleton_1 should decrease. if i hit skeleton_2 ,its health bar of skeleton_2 should decrease.
i have no idea how to do this. Can someone please help me .

The Instantiate function returns a reference to the object that it instantiates. You can just store that reference in a variable. Then you can get a reference to the slider using getComponent.

1 Like

Well that worked…thanks a bunch.