This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-04-23 22:15:51

subzero4
Scratcher
Registered: 2008-04-20
Posts: 5

How do you make gravity??

I was always trying to make a planet orbit around another planet depending upon a "gravity" variable, which you can change using the slider, but I tried so many times and I couldn't find out. I was wondering if somebody knew how to do this? Thanks!

Offline

 

#2 2008-04-24 01:42:05

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: How do you make gravity??

Simulating an orbit using a gravity variable would be rather complicated, as you would need to carry out angular momentum calculations.

You could make a shape orbit another by simply telling it how to move (move x steps, turn y degrees) where x is the perimiter of your circle divided by the number of "steps" and y is 360 divided by the number of steps.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#3 2008-04-24 08:41:17

EdnaC
Scratcher
Registered: 2007-08-28
Posts: 100+

Re: How do you make gravity??

The Gravity part of orbiting isn't too big a deal.  If you try "MoonLander", you'll see a simulation of gravity:

http://scratch.mit.edu/projects/EdnaC/48110

The difficult part is achieving a stable orbit, your velocity for a particular radius has to be just so to keep orbiting.  The proximity bomb in GravArena does a pretty good job of achieving a stable orbit:

http://scratch.mit.edu/projects/EdnaC/110327

Press down arrow in this game to drop the proximity bomb, you'll notice that it will fall into a stable orbit pretty easily, even though what it is orbiting is moving.  (I'm not entirely sure why it works so well, but for its purpose in the game, it's great.) 

You may want to download this project as a start and examine the ProximityBomb sprite.  It uses sensing blocks to respond to the gravity of another sprite, so you'll need to either keep that sprite in your new project, or recreate it and "reconnect" the sensing blocks if you start "from Scratch" on a new project.

-MrEd

Last edited by EdnaC (2008-04-24 11:52:51)

Offline

 

#4 2009-09-24 06:36:33

Jamohyperturbopro
Scratcher
Registered: 2009-06-25
Posts: 8

Re: How do you make gravity??

I made a project that matches your description, you also change the mass of the two planets. to have more planets would make it run slower and need lots of interactions listed in the scripts but I haven't uploaded it yet.

I have however uploaded the older version that i made when i wasn't as good at scratch. you can look at the scripts. the only thing is that the planets only have four directions of attraction, thats why they find it hard to get to each other.}>

Offline

 

Board footer