Function works too fast on build.

I have a function that instantiates a bullet after the mouse is held down and then let go. While the mouse is held down, the force of the bullet increases incrementally until the mouse button is let go and the bullet is shot at designated force.

My problem is that I wrote the function using GetMouseDown, and when I build the game...GetMouseDown fires way faster than in the editor.

Here's what it looks like:


shotForce +=1



//instantiate bullet
//apply force to bullet, multiply baseForce by shotForce.


The calculations work fine, its just that the shotForce increases way to fast and negates the whole point of being able to charge up your shot.

Does anyone know if you can slow down how often the GetMouseDown returns?

Or if someone has any suggestions on how to better approach this problem, it would be greatly appreciated.

You should try something like shotForce += Time.deltaTime * speed; where speed is a value which sets how fast shotForce increases.

That'll make it so that it's the same no matter what FPS you're getting