Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make sprites glide/spin smoothly?
- Obsolescence
-
Scratcher
23 posts
How to make sprites glide/spin smoothly?
I ask because I've been thinking about making “edits” on scratch. For context, people usually make edits of their favorite character using images or clips of animation, but sometimes I've seen people let the frames spin, glide, or shake. I want to try making projects like this with my own OCs. I've attempted a project with some gliding in it, but I wouldn't call it “edit” quality. Is there a way to make the gliding smoother?
- supergamer10000
-
Scratcher
1000+ posts
How to make sprites glide/spin smoothly?
You could use multiple glides
glide (3) secs to x: (0) y: (50)
glide (1) secs to x: (0) y: (55)
glide (0.5) secs to x: (0) y: (58)This code will make it near smooth gliding.
- quackdmr
-
Scratcher
37 posts
How to make sprites glide/spin smoothly?
A really good way to make gliding super smooth
Ignore the rest if you dont want the code explained.
Find the difference between our x position, and the one we want to arrive at. Divide it by 6 so its smooth.
(ps: you can do this with anything, like rotation. Instead, set it to be
)
when green flag clicked
forever
change x by (((glidex) - (x position)) / (6))
change y by (((glidey) - (y position)) / (6))
end
Ignore the rest if you dont want the code explained.
Find the difference between our x position, and the one we want to arrive at. Divide it by 6 so its smooth.
your (welcome v)
(ps: you can do this with anything, like rotation. Instead, set it to be
turn cw () degreeswith glidex and glidey as the direction instead of the position, and the
directionblock for the x/y position.
)
Last edited by quackdmr (Oct. 1, 2021 19:42:44)
- orangetheory
-
Scratcher
500+ posts
How to make sprites glide/spin smoothly?
Here is a block that I usually use when making intros to make it glide and spin smoothly.
Please note that to make it go faster, the number for the input “speed” should be lower, and to make it go slower the number should be higher.
Hope this helped!
define smooth glide: (x) (y) (dir) (speed)
repeat until <<(round(x position)) = (round (x))> and <<(round(y position)) = (round(y))> and <(round(direction)) = (round(dir))>>>
change x by (((x) - (x position)) / (speed))
change y by (((y) - (y position)) / (speed))
turn cw (((dir) - (direction)) / (speed)) degrees
end
go to x: (x) y: (y)
point in direction (dir)
Please note that to make it go faster, the number for the input “speed” should be lower, and to make it go slower the number should be higher.
Hope this helped!
- amagamecode
-
Scratcher
500+ posts
How to make sprites glide/spin smoothly?
If you want to make a sprite that guides to your mouse-pointer, here is the script:
when green flag clicked
forever
point towards (mouse-pointer v)::motion
move ((distance to (mouse-pointer v)::sensing) / (4)) steps
end
Last edited by amagamecode (Feb. 4, 2025 03:41:10)
- Discussion Forums
- » Help with Scripts
-
» How to make sprites glide/spin smoothly?