# Black Hole Gravity

Get help using Construct 2

### » Fri Dec 13, 2013 8:24 pm

Sorry about the repeat! I know there's a post about this somewhere, but I've been searching for the last half hour and can't find it anywhere.

I'd like to have the system set up so that gravity increases the closer you get to an object, and decreases the further away you get.

I've seen this work before, and I have a feeling it ends with *-1, but I'm not sure how to get this sorted.

It's like a reverse distance. I want a number to get higher the closer it is.
B
97
S
20
G
8
Posts: 1,062
Reputation: 12,725

### » Fri Dec 13, 2013 9:08 pm

If your vision so exceeds your ability, then look to something closer.
Moderator
B
142
S
32
G
89
Posts: 5,812
Reputation: 62,218

### » Fri Dec 13, 2013 9:15 pm

@zenox98

Yeah, I saw that one, but it's more complicated than what I had in mind. I used to be able to do this with a single event. The thread I remember has got a picture which shows a planet, and a series of 'zones'. Each one pulls stronger the closer it gets.

Someone then came along and told the poster how they can improve this... but I can't remember who, or what. Trying to look back to my old posts to see if I commented on it, but I can only look back 10 pages apparently...
B
97
S
20
G
8
Posts: 1,062
Reputation: 12,725

### » Fri Dec 13, 2013 9:48 pm

B
71
S
22
G
281
Posts: 3,842
Reputation: 154,886

### » Fri Dec 13, 2013 9:56 pm

@blackhornet

Nope

Thanks for trying though! I'm starting to wonder if I made the whole thing up.

It was something like:

1-(distance(x1,y1,x2,y2)/1000)

*EDIT - Turns out that was it! Weird...

Thanks everyone!!!AnD4D2013-12-13 22:02:49
B
97
S
20
G
8
Posts: 1,062
Reputation: 12,725

### » Fri Dec 13, 2013 10:31 pm

New question though!

How do I increase the gravity pull, not only based on the distance, but also on the size of the object?

So the larger the object, the greater the pull of gravity.
B
97
S
20
G
8
Posts: 1,062
Reputation: 12,725

### » Sat Dec 14, 2013 1:49 am

I settled for:

X/distance(X1,Y1,X2,Y2)

X = the mass or size or density of the object.
B
97
S
20
G
8
Posts: 1,062
Reputation: 12,725

### » Sat Dec 14, 2013 8:51 am

I did a basic gravity simulator a while ago but lost the .cap file

i remember the equation though

multiply the two masses, and then divide by the distance between the two.
you can then multiply that whole thing by a constant to fine tune how strong you want it.

i was using physics so it was

((body.physics.mass*body2.physics.mass)/distance(body.x,body.y,body2.x,body2.y))*constant

apply that force to both the body's towards each other. It worked perfectly

edit: i forgot, the distance between the bodies was squared
http://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitationkeepee2013-12-14 08:53:22
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

### » Sun Jul 06, 2014 4:25 pm

this is interesting
B
13
S
5
G
1
Posts: 119
Reputation: 2,292