- Home /
2d Sprites automatically round their scale to the nearest hundred
I assume this is some function of Unity (though I am not sure.) if it is, is there a way to turn it off? if it matters here is my code.
using UnityEngine;
using System.Collections;
public class BarCounter : MonoBehaviour {
public int maxVirtual;
public int maxGraphical;
public int value;
public string type;
public Vector3 refferencePoint;
void FixedUpdate(){
if(type == "health"){value = PublicMethods.health;}
else if(type == "mana"){value = PublicMethods.mana;}
else if(type == "progress"){value = PublicMethods.progress;}
transform.localScale = (new Vector3((maxGraphical / maxVirtual) * value,1,1));
transform.position = refferencePoint + new Vector3((((maxGraphical / maxVirtual) * value) / 2) * 0.04F - 5,0,0);
}
}
maxVirtual is the statistic's max. maxGraphical is the max length I want the bar to be.
Comment
I'm not entirely sure :( Probably losing precision during conversion from integer to internal type.
Best Answer
Answer by smoggach · Nov 13, 2014 at 06:57 PM
have you tried performing your calculations with floats instead of ints?
Your answer
Follow this Question
Related Questions
Unity 2d Sprite size 1 Answer
Scaling my background Sprite to fill screen? (2d) 2 Answers
Changing Scale Effect Physics? 1 Answer
Unity 5.6 Creating a Distortion in Sprites? 1 Answer
Is there a way to optimize animators? 3 Answers