rect.width gets set to 0 for unknown reason

So i’m having an odd issue with my health bar. To try and decrease health, what i did was use two textures one on top of another. The front is the health, the back is the background

to show a loss of health, I divided the current health and the max health, then multiplied it by the width of the background, so it becomes a percentage of the background width. But in the editor when playing my game, once the current health becomes anything below the max health it automatically goes to width 0, displaying as if there’s no health!

Hopefully that makes sense, if not i’ll try to elaborate

Here’s my code:

    public int maxHealth = 100;
	public int curHealth = 100;
	public Texture2D healthBarFront;
	public Texture2D healthBarBack;
	public float healthBarWidth = 80;
	public float healthBarHeight = 8;
	public float above;
	Rect rect; 
	Rect rectFront;
	public float rectFrontWidth;//This is just used for me to view in the inspector
	// Use this for initialization
	void Start () {
		rect.width = healthBarWidth;
		rect.height = healthBarHeight;
	// Update is called once per frame
	void Update () {
		rectFrontWidth = (float)rectFront.width; //Again, just for inspector
	//Drawing healthbar
	public void OnGUI() {
            //finding the position
		Vector3 v3pos;
		v3pos = transform.position;
		v3pos.y += above;
		v3pos = Camera.main.WorldToScreenPoint(v3pos);
		v3pos.y = Screen.height - v3pos.y;
		//Transffering into a Rect (The background)
		rect.x = v3pos.x - healthBarBack.width /2;
		rect.x += xoffest;
		rect.y = v3pos.y - healthBarBack.height /2;

		rectFront = rect;
          //This next line is where the problem is. Width gets set to 0 if curHealth is less than maxHealth
		rectFront.width = (curHealth/maxHealth) * healthBarWidth;

		GUI.DrawTexture(rect, healthBarBack);
		GUI.DrawTexture(rectFront, healthBarFront);

You’re using integer division; either use floats instead of ints, or else cast to float when doing the division.