If you need to make it slower, you need to use smaller numbers. You can just plug in 0.02f instead of 2f on line 23 and that would make it slower. But, a better idea would be to use 2f * Time.deltaTime. deltaTime is “the amount of time this frame took”, so using it here will keep the movement at a constant speed even if the framerate is different. The number you multiply it by (here, 2f) can be thought of as “number of units per second”.
So here’s the thing if you add 2 to a position in update it might not produce the results you’re expecting,
If the game runs at 60 FPS it will add 2 to the position 60 times, if the game run at 35 FPS it will add 2 35 times,
To avoid this we use Time.deltaTime, Time.deltaTime gives you the time the game took to get from the previous frame to the current frame, So you need to do this 2 * Time.deltaTime and add it to the position, So
If you’re getting a lot of FPS the TIme.deltaTIme value will be very small and if the FPS is very low Time.deltaTime value will be bigger, If you don’t understand this please do ask, Anyway when you multiple it with Time.deltaTime you will need to change your 2 to a bigger value so do check which value gives you the result you want.
Any time you would accumulate a value (add movement to position for example), use it.
Instead of:
position += movement;
do:
position += movement * Time.deltaTime;
In the specific case of your code, it would be lines 23 and 34 in the above codelet.
HOWEVER, expect Time.deltaTime to be on the order of 1/20 to 1/60 or so, depending on framerate, so you may need to scale up your current movement rates otherwise they will seem very slow. But with Time.deltaTime they will be framerate-independent.
One line 23 you’ve this temp.y += 2f; Change it to temp.y += (2f * Time.deltaTime), Keep in mind you might need to change the value 2 something higher like 50 or something bigger, Just keep changing the value until you don’t like it’s speed.