I know it's been asked a lot but I can't find the best solution for mine this whole day. I'm new in programming, so I have a health bar which is a child of my character which is position above it. My script is working but not the way I want it to. the local position is not decreasing as the health does and the scales size is bigger. Now I have tried several tweeks but I just could not figure it out.
Here is my code attached on the healthbar object :
Vector3 mylocalScale;
void Start() {
mylocalScale = transform.localScale;
}
void Update() {
mylocalScale.x = PlayerHealthSystem.PHS.P_Health;
transform.localScale = mylocalScale;
}
this is the current health bar behaviour on how it it decreases which is not I want.
my desired result it should decrease from left to right, can anyone help me to do this and understand how to do it? thanks.