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:
if(Input.GetMouseButton(0)){
shotForce +=1
}
if(Input.GetMouseButtonUp(0)){
//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.