Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Variable on a delay?
- ZiqwerkelSharda
-
25 posts
Variable on a delay?
Is there a way to make a variable the same as another variable which is constantly updated, but as it was half a second in the past? E.g. if Variable 1 goes from 1 to 2, I want Variable 2 to have the value of 1 for a half-second longer before it turns to 2.
- ZiqwerkelSharda
-
25 posts
Variable on a delay?
Pardon me if I'm wrong, but doesn't that code simply set val2 to be equal to val1 every half-second? I'm looking to be able to make a sprite “follow” the player character through this method.
- PutneyCat
-
500+ posts
Variable on a delay?
You could maybe use a list to store all the val1 values for the half second.
If the half-second doesn't need to be super-precise just experiment with the max length of the list so that it ends up storing about a half second worth of values.
If the half-second doesn't need to be super-precise just experiment with the max length of the list so that it ends up storing about a half second worth of values.
Last edited by PutneyCat (Nov. 17, 2018 10:20:19)
- deck26
-
1000+ posts
Variable on a delay?
Sorry, you're right. Pardon me if I'm wrong, but doesn't that code simply set val2 to be equal to val1 every half-second? I'm looking to be able to make a sprite “follow” the player character through this method.
@PutneyCat probably has the right idea.
- Discussion Forums
- » Help with Scripts
-
» Variable on a delay?