- Home /
Float bug... no errors.
public float timeToSpaComet = 50f;
public float timeBetweenWavComet = 0f;
public float timeToSpaStar2 = 2f;
public float timeBetweenWavStar2 = 0f;
void FixedUpdate ()
{
Debug.Log(timeBetweenWavComet); //Outputs: 50
Debug.Log(timeBetweenWavStar2); //Outputs: 2
Debug.Log(timeToSpaComet); //Outputs: 20
Debug.Log(timeToSpaStar2); //Outputs: 1
}
Is this a bug? Or wat xd?
@inblinder Try this:
void FixedUpdate ()
{
Debug.Log("timeBetweenWavComet: " + timeBetweenWavComet); //Outputs: 50
Debug.Log("timeBetweenWavStar2:" + timeBetweenWavStar2); //Outputs: 2
Debug.Log("timeToSpaComet:" + timeToSpaComet ); //Outputs: 20
Debug.Log("timeToSpaStar2: " + timeToSpaStar2); //Outputs: 1
}
Answer by Bonfire-Boy · Feb 13, 2018 at 03:44 PM
They're public variables so we have no reason to suppose that their values are the ones shown in their declarations. They could have been set in the inspector or by any code that has a reference to the component. So check the inspector (if it's a scene object or one created from a prefab), and search for references to the fields in the code.
I took the liberty to convert your comment to an answer, as I am 99.999% sure you are right.
I've made them private... ---> no errors but it fixed my problem. Thanks a milion. :D weird problem
That suggests that the default values had been changed in the inspector, overriding them. By making them private the fields were no longer exposed to the inspector and so the overrides went away.
Your answer
![](https://koobas.hobune.stream/wayback/20220612152541im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Float sets itself to zero 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to fix wobbling float when away from spawn? 1 Answer
Make sure levels assets are loaded before switching? 1 Answer