Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do you change x speed by the timer??
- _plaz
-
Scratcher
23 posts
How do you change x speed by the timer??

i have a set of code where an sprite moves by a current amount of speed
but because scratch is scratch, the sprite sometimes lags out and that messes with the project
i know the timer can fix framerate and stuff, so is there anyway to help stop lag by using the timer someway on this script?
- MultiTasker801
-
Scratcher
100+ posts
How do you change x speed by the timer??
you could use a variable to track the timer and each frame use something like the following to calculate frame time and then figure out how much different every action needs to be
you'll never “fix” lag on scratch but you can always try to work around it
when green flag clickedi might be completely mis-interpreting your question, but i think this is the kind of fix you're looking for?
forever
set [deltatime v] to ((oldtimer)-(timer))
set [timemultiplier v] to ((deltatime) * [30]) // use this value to change the amount sprites move and such
set [oldtimer v] to (timer)
end
you'll never “fix” lag on scratch but you can always try to work around it
- _plaz
-
Scratcher
23 posts
How do you change x speed by the timer??
you could use a variable to track the timer and each frame use something like the following to calculate frame time and then figure out how much different every action needs to beso how would i apply the time multiplier to the “repeat until x pos >” script?when green flag clickedi might be completely mis-interpreting your question, but i think this is the kind of fix you're looking for?
forever
set [deltatime v] to ((oldtimer)-(timer))
set [timemultiplier v] to ((deltatime) * [30]) // use this value to change the amount sprites move and such
set [oldtimer v] to (timer)
end
you'll never “fix” lag on scratch but you can always try to work around it
- Discussion Forums
- » Help with Scripts
-
» How do you change x speed by the timer??