- Home /
Why isn't my number increasing?
I have created a float number called speed and ,in the update function, made it increase. But it doesn't actually increase. It might be useful to know that the script is assigned to a prefab Any help would be greatly appreciated :)
void Update()
{
transform.position += Vector3.left * speed * Time.deltaTime;
speed += 0.005f;
}
Post edited due to duplicated content, and unnesseary code.
Answer by tormentoarmagedoom · Feb 14, 2020 at 06:47 PM
Hello.
First, is the speed variable defined as static? (you dont want it static).
Second, are you sure speed is not increasing? it should.
To be sure, add a debug.log ro know its value each time is used:
void Update()
{
Debug.Log(speed);
transform.position += Vector3.left * speed * Time.deltaTime;
speed += 0.005f;
}
And check the value. maybe is increasing very slow and you dont see it.
Byee!
I'm sorry for wasting your time it actually was increasing. I didn't know until the Debug.Log statement so you did help. I didn't notice due to the fact that on prefabs it woudn't update it unless it was in the seed Thanks :)
Your answer
Follow this Question
Related Questions
Render Numerical Values w/o Using GUI.* 1 Answer
hierachy order is not in any order 2 Answers
Can't hold number types in sqlite table 0 Answers
Generate a random number that is different every time? 1 Answer
Random number with exceptions? 2 Answers