Hey everybody, so I’m making my first game in unity. I’m using the sample 2d character controller to make an infinite runner and I’d like to increase the players speed by 1% each second.
Currently I’m using
public float maxSpeed = 10f; // The fastest the player can travel in the x axis.
[SerializeField] float jumpForce = 400f;
private float increaseAmount = 0.01f;
void OnGUI()
{
GUI.Label(new Rect(10, 20, 150, 30), "Speed: " + (float)(this.maxSpeed));
}
void start(){
InvokeRepeating("IncreaseSpeed", 1, 1);
}
void IncreaseSpeed()
{
maxSpeed += increaseAmount;
}
But nothing is happening, The players speed is being outputted to the GUI but no speed increase is happening.
Anybody have any ideas?
Help is greatly appreciated.