- Home /
Changing the thing to take decimal values....
In my script I set the camera to be 5 units to the right in the x axis like so:
var targetGO : Transform; var change : int; var cameraX : int;
function Start() {
}
function Update () {
cameraX = transform.position.x + change;
targetGO.position = Vector3(cameraX, 2, -10);
}
The only problem is that when I apply a Constant Force it doesn't follow the gameObject when it is a decimal value and only follows when it hits an integer. How can I make the camera follow even through decimal values?
Answer by Mike 3 · Nov 24, 2010 at 10:39 PM
Set both change and cameraX to float instead of int (cameraX is mandatory, changing change as well will let you set values which aren't integers from the inspector)
var change : float;
var cameraX : float;
Also, since you seem to be really good at coding. Could you answer this question of $$anonymous$$e? http://answers.unity3d.com/questions/28656/a-few-spritemanager-questions
Your answer
Follow this Question
Related Questions
I dont want Decimals :P 1 Answer
GUI.HorizontalSlider precision 3 Answers
int myX = (int)transform.position.x; 1 Answer
print to only two decimal places. 2 Answers
C# divide float by integer 2 Answers