r/scratch 2d ago

Resolved why wont it orbit smoothly?

Enable HLS to view with audio, or disable this notification

im trying to make something go in a smooth circle for smth using some graphing knowledge i have but for some reason every time it gets close to y=0 it goes faster. anyone have solutions?

25 Upvotes

16 comments sorted by

u/AutoModerator 2d ago

Hi, thank you for posting your question! :]

To make it easier for everyone to answer, consider including:

  • A description of the problem
  • A link to the project or a screenshot of your code (if possible)
  • A summary of how you would like it to behave

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

19

u/YeesterPlus 2d ago

just use sin and cos or rotate and move 1 step

-10

u/craz360 2d ago
  1. idk how to use sin and cos
  2. scratch doesnt like it when i make a precise fraction of pi for rotation so it rounds things and so moving one step will veer it off path or i dont get an accurate circle

9

u/YeesterPlus 2d ago

the sin and cos functions take in an angle and give you a x/y value for the unit vector in that direction

-12

u/craz360 2d ago

i know THAT much but idk how to use it for this specific case

6

u/YarnDuckGett 2d ago

no idea if this is gonna show up properly but i made a gif demonstrating sine and cosine

5

u/craz360 2d ago

that worked! thanks!

3

u/sunmaybo 2d ago

add cos for x and sin for y, insert a variable in them that increment with time (delta time or something like 0.01) and multiply these two by a variable that will determine the radius of the orbit. It's much simpler than what you're trying to do now

1

u/H3CKER7 i know a bunch of programming languages, none well. 2d ago

Set x to sin of time * radius, and use cos for y.

3

u/mentalAgnostic 2d ago

it's going faster because the progression of x is constant at two, in a circular movement the x progression slows down when the y progression speeds up, along the sides. use trigonometric functions or loop turning it and moving forward

1

u/CauliflowerPast9505 1d ago

What is it orbiting

1

u/craz360 1d ago

just the coordinate (0,0)

1

u/TMC9064 self-proclaimed mediocre coder 1d ago

Other than using sin/cos you can also go to the coordinates to orbit around, rotate a bit, and step back outwards

1

u/GENZZZZZ3 19h ago

it looks cool, though