Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Strafing
- FalconGunner99
-
1000+ posts
Strafing
I asked this in /helpwithscripts/ but everyone got really confused for some reason.
Is there a way to make a sprite strafe?
As in move sideways relative to the sprite, rather than x and y.
Just in case, here's an example:
I want the sprite to be pointing this way:

And moving this way:

Is there a way to make a sprite strafe?
As in move sideways relative to the sprite, rather than x and y.
Just in case, here's an example:
I want the sprite to be pointing this way:

And moving this way:

- liam48D
-
1000+ posts
Strafing
Probably like this:

Or you could do this for more control:
Hope I helped!

- nathanprocks
-
1000+ posts
Strafing
Trigonometry is the best way as it doesn't require rotating the sprite before moving it.
- liam48D
-
1000+ posts
Strafing
That's a bit more advanced though and may confuse Scratchers who don't know how to use trigonometry. 
Then again, this is the advanced topics.

Then again, this is the advanced topics.

- MathWizz
-
100+ posts
Strafing
Note that changing x and y individually will make any pen marks in a jagged fashion. It probably won't be an issue in most cases but is something to keep in mind if you plan on using the pen.
- FalconGunner99
-
1000+ posts
Strafing
Ah but there is a reason I posted here, that trig was exactly what I'm looking for That's a bit more advanced though and may confuse Scratchers who don't know how to use trigonometry.
Then again, this is the advanced topics.

- FalconGunner99
-
1000+ posts
Strafing
Perfect! Thanks for the math help. Trigonometry is the best way as it doesn't require rotating the sprite before moving it.
Yup, I figured, but pen isn't an issue for the project I'm using Note that changing x and y individually will make any pen marks in a jagged fashion. It probably won't be an issue in most cases but is something to keep in mind if you plan on using the pen.
- NickyNouse
-
1000+ posts
Strafing
I know this is resolved but I just wanna say, setting x and y individually on pen projects has caused me so much stress you don't even know Note that changing x and y individually will make any pen marks in a jagged fashion. It probably won't be an issue in most cases but is something to keep in mind if you plan on using the pen.
- FalconGunner99
-
1000+ posts
Strafing
I'll bet. Pen is finicky at best.I know this is resolved but I just wanna say, setting x and y individually on pen projects has caused me so much stress you don't even know Note that changing x and y individually will make any pen marks in a jagged fashion. It probably won't be an issue in most cases but is something to keep in mind if you plan on using the pen.
- davidnallen11
-
27 posts
Strafing
Are you able to make a strafing script wit variables?Can you adjust the speed of the strafe?
- davidnallen11
-
27 posts
Strafing
Are you able to make a strafing script wit variables?Can you adjust the speed of the strafe?
I mean the Trigonometry one
- BookOwl
-
1000+ posts
Strafing
Please don't necropost. I assume that you could just change the input to the block. Are you able to make a strafing script wit variables?Can you adjust the speed of the strafe?
- davidnallen11
-
27 posts
Strafing
Please don't necropost. I assume that you could just change the input to the block. Are you able to make a strafing script wit variables?Can you adjust the speed of the strafe?
Actually I have no idea about the more blocks section.I always avoided it when possible
- pixelmeap
-
1 post
Strafing
What if I am using… (The trigonometry)
Either I am very dumb or it doesn't work like that, also, do you put it on the button you use to usually turn? (Like if I were using WASD and A was turn 90 degrees.)
- _nix
-
1000+ posts
Strafing
Asking a question related to an old topic is fine. Please don't necropost (post on an old topic).
Maybe learn about what “necroposting” is okay before requesting someone doesn't necropost at all?

- NickyNouse
-
1000+ posts
Strafing
Nathanp's code should work no matter what direction the sprite is facing: What if I am using… (The trigonometry)Either I am very dumb or it doesn't work like that, also, do you put it on the button you use to usually turn? (Like if I were using WASD and A was turn 90 degrees.)
To move sideways to the sprite, you would use the block like this: Trigonometry is the best way as it doesn't require rotating the sprite before moving it.
And yeah, you would put it on the button you use to turn.
Last edited by NickyNouse (Dec. 16, 2016 20:07:06)
- Falloutcollab
-
1 post
Strafing
hate to be a necromancer,but
its not working for me. the sprite just goes towards the corners
its not working for me. the sprite just goes towards the corners
- 5632622roblox
-
100+ posts
Strafing
That's a bit more advanced though and may confuse Scratchers who don't know how to use trigonometry.
Then again, this is the advanced topics.
tbh yeah
but like im in 9th grade and i get it perfectly and dont even know what trigonometry is
in fact ive applied this quite a few times in stuff like raycasters (i made a maze-like one in smilebasic and i also made one in computercraft (minecraft))
- Discussion Forums
- » Advanced Topics
-
» Strafing