Could someone explain me why is mathf.clamp not claming value of normalizedValue ?
I tried using clamp in several ways before asking, but it jsut seems to be not affecting anything.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HealthBar : MonoBehaviour
{
public float displayedMaxValue=100;
public float displayedCurrentValue=100;
private float normalizedValue;
public Transform bar;
// Start is called before the first frame update
void Start()
{
displayedCurrentValue = -50;
}
private void Update()
{
Mathf.Clamp(normalizedValue = displayedCurrentValue / displayedMaxValue, 0, 1);
bar.localScale = new Vector3(normalizedValue,1f,1f);
}
}