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

#1 2012-03-31 11:10:53

ZapLightning
New Scratcher
Registered: 2012-03-29
Posts: 30

Magnetic Field

How do I make a magnetic field that attracts different objects? It is for my game Magnetism.

Offline

 

#2 2012-03-31 11:25:07

MorgulFan
New Scratcher
Registered: 2012-03-29
Posts: 31

Re: Magnetic Field

ZapLightning wrote:

How do I make a magnetic field that attracts different objects? It is for my game Magnetism.

when gf clicked
 forever
  point towards [magnet v]
  move (however many steps you want depending on speed) steps

Offline

 

#3 2012-03-31 11:29:42

ZapLightning
New Scratcher
Registered: 2012-03-29
Posts: 30

Re: Magnetic Field

No like angry birds space... Gravity...  smile

Offline

 

#4 2012-03-31 14:21:44

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: Magnetic Field

Like the planets in Angry Birds Space...

Last edited by coolhogs (2012-03-31 14:23:19)


Get ready for domination of:  tongue

Offline

 

#5 2012-03-31 15:27:42

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Offline

 

#6 2012-04-01 00:55:30

henrystanley
Scratcher
Registered: 2010-05-03
Posts: 14

Re: Magnetic Field

What you need is to create a script that tells the desired object to turn towards the gravity simulating object the closer it gets...

Offline

 

#7 2012-04-01 01:41:58

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Magnetic Field

Use the inverse square law:

when gf clicked
forever
point towards [a massive object v]
move ((size)/(distance to [a massive object v])) steps
point towards [another massive object v]
move ((size)/(distance to [another massive object v])) steps
//...
wink


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

Board footer