Can a shape have it's own gravity.
-
- Posts: 1
- Joined: Sat Sep 11, 2010 4:11 pm
- Contact:
Can a shape have it's own gravity.
Is it possible for have an object/shape to have its own gravity. It would basically be like a planet where when things float by the planet it would start to draw them closer depending on the distance between the object and the planet.
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Can a shape have it's own gravity.
Not trivially, but you can calculate your own forces each frame or use integration callbacks to calculate gravity on the fly. Check out the Planet demo that comes with Chipmunk.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 81
- Joined: Fri Aug 27, 2010 1:00 am
- Contact:
Re: Can a shape have it's own gravity.
this might be a silly idea but if you want a simple physical pull towards your planet you could use a dampend spring constraint between your planet and your object and remove the constraint if the object gets to far.
not the cleanest solution for a game that depends on the gravity on the long run but maybe less tedious than calculating gravity on the flight ^^
not the cleanest solution for a game that depends on the gravity on the long run but maybe less tedious than calculating gravity on the flight ^^
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Can a shape have it's own gravity.
While that would sort of work, it wouldn't produce a very gravity like force. Gravity gets weaker the farther away you get, springs get stronger.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: No registered users and 7 guests