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 my current healthbar size when on play mode
I want it to remain to small that I set it to.
and this is my desired healthbar behaviour that decreases from right to left, somehow I cant figure out how to do: