Imagine that they are superimposed on each other. You need to implement healthBar by moving the child green rectangle relative to the red parent.

PS Please do not offer other options, I know about them, you need this way.

PSS MB code help, which is now

SliderRect.transform.localScale = new Vector3 ( currentHealth / maxHealth, 1.1f, 1); if(SliderRect.transform.localPosition.x == 0f) { SliderRect.transform.localPosition = new Vector3 (-(1 - (currentHealth / maxHealth)), 0,- 0.001f); } 
  • Please clarify what is not working or what is wrong? When implementing nested image, you most likely need to use a mask, have you tried? A screen or picture of the expected result would also be very useful. - Egor Bashinsky
  • Added an example with a picture - Imagine that they are superimposed on each other - TEA
  • What do you mean by the phrase "in relation to the red parent"? You make a green child, and accordingly the zero coordinates are the "full" state of the healthbar, and the width of the red is the distance you need to move the green to get the "empty" state. - Artem Cherevan
  • The problem is that if you change the scale, then the shape will change from both sides towards its center. I tried to solve the problem by changing the scale + transform to the left. But, unfortunately, this does not work as desired. As a result: I solved the problem by changing the heathbar "a prefab, but these are crutches, so to speak. I would like to know if there is an opportunity to do this without crutches :) - TEA
  • @TEA you do not need to change the scale, you need to change the position of the child object - Artem Cherevan

0