Physics, universe and a tiny satellite are on a boat

Hi all!

I’ve never tried a physicEngine in BJS until now, and my current objective is to have a satellite on its orbit.

So for now here what I’ve done:

  • I set gravity to 0
  • planet have a mass of 0, to not move
  • I create a DistanceJoint to stick the satellite on its orbit

Of course it seems I’m totally wrong :hear_no_evil: but I’m now stuck in my problem.

Are some guys here already tried to play with physics into space?

At start I was thinking about keeping our loved gravity to -9.81, and having the satellite friction to 0 (no air), plus a linear force onto this satellite, so it have a sufficient velocity to not fall into earth - like IRL in fact… but yeah, the satellite just fall into the infinity.

So… any help is welcome, where am I doing wrong? :slight_smile:

Well I think you try to reproduce the real world with a JS based physics engine ;D
Adding @trevordev to see if he has an idea to improve your simulation

No fear :-p

Actually, I have in the mind to made a mini-game for explaining basics orbital mechanics. So doing fake will be probably too difficult to keep realistic, this is why I started playing with PhysicEngine.

But OK I understand, it’s maybe out-of-specs ahah. Waiting for trevordev :slight_smile:

Yup I would use forces instead of a joint to better simulate, you could take a look at this https://playground.babylonjs.com/#JYN2EP#12 , its using -9.8 as a constant because I’m too lazy to use the real gravitational equation but you get the idea.

2 Likes

Looks like nice trick!

I will take a deeper look, thanks!

So after rechecking your code and take a look in Oimo doc… it looks like you have spot the exact right method, GG again :slight_smile:

Could be great to be able to set gravity on an object, in that case only a linearVelocity with 0 friction could be enough