Gravity

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
mohammadAdnan
Posts: 48
Joined: Sat Jan 26, 2013 5:54 pm

Gravity

Post by mohammadAdnan »

Hello , Norbo I am trying to make some gravity points in the sky ( as game play ) which grab the player toward it when he is flying , those acts as gravity points in the sky and they will grab the player if he is close to them

Q : How to make those Gravity points Norbo?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Gravity

Post by Norbo »

A GravitationalField, one of the demos force fields, would do the trick. You may want to use a BoundingSphereForceFieldShape for the shape rather than an InfiniteForceFieldShape, though. Check out the PlanetDemo for an example.
mohammadAdnan
Posts: 48
Joined: Sat Jan 26, 2013 5:54 pm

Re: Gravity

Post by mohammadAdnan »

thanks Norbo I found PlanetDemo.cs and I can't found the first one, for the Thurster class it seems that you made changes to the latest BEPU engine , so how to get it in the new version ?

Code: Select all

var thruster = new Thruste(ship, new Vector3(0, -2, 0), new Vector3(0, 300, 0), 0);
            Space.Add(thruster);
this gives errore
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Gravity

Post by Norbo »

The Thruster is just an example class contained in the BEPUphysicsDemos.
mohammadAdnan
Posts: 48
Joined: Sat Jan 26, 2013 5:54 pm

Re: Gravity

Post by mohammadAdnan »

Thanks Norbo , while I am thrown away due to Gravity field , how to check how far I am from the ground ?? ( Suppose I am flying after shocked by the gravity field and now I am in the air far from the ground Ok Nobo !! )
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Gravity

Post by Norbo »

If the ground can be considered a single flat plane, or if altitude can be considered from some fixed reference point like sea level, then you can just subtract the 'ground' height from the height of the character (usually the entity.Position.Y, unless you're using a different axis interpretation).

If you don't know the ground's height, you could send a ray cast in the down direction to find it.
Post Reply