Black Hole Gravity

Get help using Construct 2

Post » 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.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Fri Dec 13, 2013 9:08 pm

What about THIS?
If your vision so exceeds your ability, then look to something closer.
Moderator
B
131
S
29
G
81
Posts: 5,328
Reputation: 56,630

Post » 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...
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Fri Dec 13, 2013 9:48 pm

ImageImageImage
B
71
S
21
G
220
Posts: 3,646
Reputation: 123,721

Post » 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
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » 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.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » 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.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » 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

Post » Sun Jul 06, 2014 4:25 pm

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


Return to How do I....?

Who is online

Users browsing this forum: Magistross, tarek2 and 2 guests