Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I tween two numbers?
- connor9767
-
3 posts
How do I tween two numbers?
I was wondering how I can tween a number (ex. number1) to another number (ex. number2). If there is a way to tween numbers, how could I make it follow a sine wave in/out like in Luau?
- yadayadayadagoodbye
-
1000+ posts
How do I tween two numbers?
You'd likely have to make a custom function for it, but the idea is basically to use an equation to convert one number to another smoothly, so I would believe something like
(num1 is the start while num2 is the goal)
num1+(num2-num1)/(tween speed ig?)
for a linear tween, and a similar logic can be applied if you want, say, a tween that slows down/speeds up
(as in, adding a portion of the difference between the two numbers onto the first number, with the portion being the part that changes each second or something)
(num1 is the start while num2 is the goal)
num1+(num2-num1)/(tween speed ig?)
for a linear tween, and a similar logic can be applied if you want, say, a tween that slows down/speeds up
(as in, adding a portion of the difference between the two numbers onto the first number, with the portion being the part that changes each second or something)
- connor9767
-
3 posts
How do I tween two numbers?
Turns out, someone made custom blocks for it: https://scratch.mit.edu/projects/599233609/
- Discussion Forums
- » Help with Scripts
-
» How do I tween two numbers?