Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Movement and Rotation with variables
- HoiTemmieColeg
-
20 posts
Movement and Rotation with variables
Ok, so in one of the projects I'm working on, one of the sprites moves based off of a variable changing, not steps or set x and y. It has to work based on the variable changing. Imagine the variable is
If I have the sprite roatated in a certain direction, how could I have it move in that direction, but without using
Last edited by HoiTemmieColeg (Dec. 11, 2018 03:10:58)
- HoiTemmieColeg
-
20 posts
Movement and Rotation with variables
Oops the formatting was messed up. The last line was meant to say
If I have the sprite roatated in a certain direction, how could I have it move in that direction, but without usingbecause it wouldn't update the variable.
- deck26
-
1000+ posts
Movement and Rotation with variables
Don't understand what you mean. Moving using a variable doesn't change the variable.
- HoiTemmieColeg
-
20 posts
Movement and Rotation with variables
OK what I'm trying to say is that the project I'm making cannot use move () steps. To move my sprite, I have to change a variable Don't understand what you mean. Moving using a variable doesn't change the variable.
How could I have him move in the direction he is facing using only
Of course you would also use math blocks, you just can't use the move () steps block
Last edited by HoiTemmieColeg (Dec. 11, 2018 11:51:59)
- PutneyCat
-
500+ posts
Movement and Rotation with variables
Maybe:
Last edited by PutneyCat (Dec. 11, 2018 13:03:59)
- deck26
-
1000+ posts
Movement and Rotation with variables
Still unsure why you're avoiding the move n steps block though.
- HoiTemmieColeg
-
20 posts
Movement and Rotation with variables
scrollx Still unsure why you're avoiding the move n steps block though.
- deck26
-
1000+ posts
Movement and Rotation with variables
So if you're scrolling you may prefer to use trigonometry to work out the x and y change. But if you'd rather not for some reason you could actually use a custom block with no screen refresh - store x,y, move n steps, calculate difference for x and y and move back again. All done in a fraction of a second.
- HoiTemmieColeg
-
20 posts
Movement and Rotation with variables
Thanks! I'll try it out. Maybe:
- HoiTemmieColeg
-
20 posts
Movement and Rotation with variables
That might work too. I'll try both and see how it goes. So if you're scrolling you may prefer to use trigonometry to work out the x and y change. But if you'd rather not for some reason you could actually use a custom block with no screen refresh - store x,y, move n steps, calculate difference for x and y and move back again. All done in a fraction of a second.
- HoiTemmieColeg
-
20 posts
Movement and Rotation with variables
Maybe:
So if you're scrolling you may prefer to use trigonometry to work out the x and y change. But if you'd rather not for some reason you could actually use a custom block with no screen refresh - store x,y, move n steps, calculate difference for x and y and move back again. All done in a fraction of a second.
I ended up using the first method. Here is a very early beta of my game:
https://scratch.mit.edu/projects/269780344/
- Discussion Forums
- » Help with Scripts
-
» Movement and Rotation with variables