Black Hole Gravity

0 favourites
  • 9 posts
From the Asset Store
A simple fun and stylish endless scroller game ready to be customized and published.
  • 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.

  • What about THIS?

  • 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...

  • this one maybe

  • blackhornet

    Nope <img src="smileys/smiley36.gif" border="0" align="middle" />

    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!!!

  • 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.

  • I settled for:

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

    X = the mass or size or density of the object.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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_gravitation

  • this is interesting

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)