Jump to content

Magnetic Asteroid Gravity


Errol

Recommended Posts

I've had this idea that I was sure would have been brought up already, but I have been unable to find any indication of this.

We all know that asteroids in KSP have no gravity, that is to say that they are treated like any other ship part, and just float around inside the physics sphere. We also know it would be very difficult both to create a mod, and for that mod to run computationally, that would add some sort of S.O.I to them.

However, in the modding community we like to take ideas that are difficult, and sufficiently abstract them so that we can make a reasonable mod for it. What if instead of giving them an SOI and everything, we just implement the already existing magnetic attraction mechanic used by docking ports? Just turn the force way down, and make it attract all ship parts. I don't know, as I am not a programmer, but it occurs to me that this may end up being very CPU intensive, so it could be perhaps just magnetic to a list of part types; such as anything that is a command pod, engine, landing leg, claw or other asteroid. This way you can "Land" on asteroids, and you can build large clumps of asteroids (space dust bunnies anyone?) if not actually orbit. And who knows, perhaps there are stable orbits that you could find with the right force level set (I'm thinking it would need to be very low).

Thoughts?

Ping: @linuxgurugamer @Snark, because I'm hoping if this is a bad idea, one of you guys could easily see why.

Edited by Errol
Link to comment
Share on other sites

1 minute ago, Errol said:

I've had this idea that I was sure would have been brought up already, but I have been unable to find any indication of this.

We all know that asteroids in KSP have no gravity, that is to say that they are treated like any other ship part, and just float around inside the physics sphere. We also know if would be very difficult both to create a mod, and for that mod to run computationally, that would add some sort of S.O.I to them.

However, in the modding community we like to take ideas that are difficult, and sufficiently abstract them so that we can make a reasonable mod for it. What if instead of giving them an SOI and everything, we just implement the already existing magnetic attraction mechanic used by docking ports? Just turn the force way down, and make it attract all ship parts. I don't know, as I am not a programmer, but it occurs to me that this may end up being very CPU intensive, so it could be perhaps just magnetic to a list of part types; such as anything that is a command pod, engine, landing leg, claw or other asteroid. This way you can "Land" on asteroids, and you can build large clumps of asteroids (space dust bunnies anyone?) if not actually orbit. And who knows, perhaps there are stable orbits that you could find with the right force level set (I'm thinking it would need to be very low).

Thoughts?

Ping: @linuxgurugamer @Snark, because I'm hoping if this is a bad idea, one of you guys could easily see why.

first off, for all  intents and purposes, an asteroid has no gravity, or so little it isn't worth dealing with.  Has to be a pretty big asteroid to have a significant gravity (ie:  >0.01g)

And, you kind of hit the nail on the head, adding yet another mechanic to the calculations of ALL the parts would just bog down the system even more

Link to comment
Share on other sites

Yeah, it's just not something useful, because KSP-sized asteroids that are just a few meters across would have gravity that's so tiny that it would take hours of being parked next to them to see significant motion towards the 'roid.  And those hours would have to be in physics warp, mind you, because "on rails" no forces get applied.

So yes, it would be easily implementable:  just add a force that attracts ships to a nearby asteroid that's within physics range.  But the force would only apply when not in timewarp (meaning you're running 4x speed at most), and the force would be so tiny that if the ship is moving at all under its own power you wouldn't even notice it, and the only way to observe any effect at all would be to, 1. park a ship right next to an asteroid, 2. perfectly kill the relative velocity to zero, i.e. not even 0.1 m/s relative, 3. do not timewarp, and 4. sit there watching it for multiple hours of your time so you can say "Hey look, now it's a few meters closer than it was!"

Doesn't seem like a very useful goal to me.  :)

1 minute ago, Errol said:

It could be further optimized by being only applied to the largest of asteroids...

Bear in mind that even the very largest class E asteroids in KSP are, what, 3000 tons or thereabouts?  If you're 100 meters away from a 3000-ton asteroid, the gravitational acceleration towards it will be 0.00000002 m/s2, i.e. only a couple of billionths of a G.

Not enough to matter even vaguely in any realistic gameplay scenario.

Link to comment
Share on other sites

Well, thanks for the replies. Worth a shot. 

Gottah admit though, being able to build asteroid clumps would be fun. I was thinking, since this is a game, perhaps the asteroids have more gravity than other objects or something. And the fact that the magnetic field doesn't kick in until you are within a certain range would limit how reality breaking this change is..

EDIT: 

So yes, it would be easily implementable:  just add a force that attracts ships to a nearby asteroid that's within physics range. 


Is this something you would be willing to take the time to explain or show how to do, for me to implement in my own game?

Edited by Errol
Link to comment
Share on other sites

12 minutes ago, Errol said:

Is this something you would be willing to take the time to explain or show how to do, for me to implement in my own game?

Well, not only would it take a lot of my time (because I don't actually know the exact right way to do this, would have to research and figure it out myself first, same as with any mod that I write)... but I also think that it wouldn't actually be as fun or useful as you think it is.

Suppose that you do implement it.  What happens then?

I think you won't like the result:

Of course, there's nothing that says you couldn't implement an unrealistically strong gravity by positing that they're somehow "magically magnetic" and have a gravity that's a hundred million times stronger than it ought to be, just so it's detectable by the player.  :)  And maybe that might be fun for a player to tinker with.

But it would cause other gameplay problems.

Bear in mind that colliders don't function in timewarp.  If you give asteroids an artificially strong gravity, what's going to happen?  You're going to get objects that cluster together:  you have an asteroid sitting there, anything nearby (ships, debris, other asteroids) will get attracted and pretty soon will be "stuck" (very lightly) to the surface, like paperclips on a magnet.  So far so good, right?

Except that they're not actually connected as a single vessel; it's just a set of different objects that are pulled together by forces and which the Unity colliders keep from intersecting each other any more deeply.  Which only works because the Unity physics engine is busily cranking through the CPU cycles, re-evaluating every collider dozens of times per second to handle all the collisions gracefully.

The instant you go into timewarp (or if you switch away to some other place and then come back later)... all of that stops.

Some of those objects are going to "drift" inside each other.  And then the moment you switch back to them, the colliders are suddenly going to freak out ("Oh noes there's a solid object inside my collider AAAAAAAGHH!") and you'll get a big explosion and probably have everything flung at lightspeed towards the corners of the solar system.

Which I assume is not what you want.  :)

(To see this kind of thing in action, try this little experiment:  1. Build a big space station. 2. Send up a little ship to dock with it. 3. Get the little ship heading straight at the space station at a slow speed, like 0.1 m/s.  3. Right before it docks... go into 5x timewarp.  4. Watch the ship as it drifts inside the space station. 5. Go out of timewarp.  6. Sit back, watch the show, and hope that your kerbals are paid up on their accidental death-and-dismemberment insurance.) 

There's basically no way to make this work in a way that would be at all fun for the player, as far as I can see, without implementing some huge complex system from scratch (supported neither by KSP or by Unity itself) to try to maintain relative state/positioning for nearby objects when they're on rails, which would be a task similar in complexity to writing a physics engine from scratch.

In short:  I can fairly confidently predict that it ain't gonna happen.

Link to comment
Share on other sites

2 minutes ago, Snark said:

...

Right, I see your point. I'm aware this has been a problem for vessels landed on planets (like bases) for years, and is the subject of a number of mods and tweaks each with their own pro's and con's. Trying to get around this would bring your right back to trying to make an asteroid be treated like a planet, which I feel like it is safe to say is beyond the scope of a MM config, and is what this idea of magnetic attraction was meant to get around. 

Link to comment
Share on other sites

11 minutes ago, Errol said:

I'm aware this has been a problem for vessels landed on planets (like bases) for years

Yep, it's difficult even for planets.

And planets are the easy case, because there are lots of things they don't have to deal with that objects do, which allows making tons of simplifying assumptions in the code.

And the devs at Squad are no dopes, and have put an awful lot of programmer-years into KSP, and have tried to solve this problem for the easy case of planets, and there are still issues.

So... what does that tell you about the scope of the difficulty of the problem?  :wink:

Solving it for objects rather than planets is a much harder problem, which means I really don't think it's going to be solved by a modder or two spending a month or two on it.  This is a seriously heavy lift.

It's not even in the same universe of difficulty as a simple MM config.  It would absolutely require code, and lots of code, and lots of unintuitive code, that would be full of subtle bugs and edge cases.  We're talking about many programmer-months (if not years) of effort.

So, if you want to hire me full time for a year or so and provide a full salary with benefits, I'll get you something that kinda-sorta works but will probably be buggy as hell unless you also hire a full-time QA staff (that's "staff", plural).  :wink:

Like I said.  Big problem.  Physics engines are hard.

Link to comment
Share on other sites

I'm having trouble getting myself hired for anything lately, let alone me being able to hire someone else. Having an assistant for my business would be helpful, but is also wishful thinking. Anyway, I'm still happy I can grab an asteroid, bring it home, and dock with it to build my space hotel.

Link to comment
Share on other sites

Yeah, I was being kinda facetious there, just trying to make a point that I'm really not exaggerating the scope of the problem.  :wink:

1 minute ago, Errol said:

Anyway, I'm still happy I can grab an asteroid, bring it home, and dock with it to build my space hotel.

Yep.  And that works because it's attached (via the klaw) and therefore part of the same vessel and therefore the game has a simple way of maintaining relative positions of things that's not dependent on physics.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...