Hi all,
I'm looking at using a Bepu Sphere to represent a planet and obviously the standard method of applying gravity in Bepu isn't of particular use here -- is there a method for applying 3D spherical gravity or should I do it by hand?
Planetary gravity
Re: Planetary gravity
Technically, you could use the GravitationalField. However, this does some extra computations to determine if objects are within range of the field. Instead, you could create a custom Updateable that applies forces. A simple example is attached.
However, something to keep in mind with large objects is floating point precision. If your planets are actually very large, and especially if they require detailed collision with objects much smaller than themselves, you will most likely encounter some inaccuracies and oddities. There's ways to deal with the issues that arise depending on what you're trying to accomplish.
However, something to keep in mind with large objects is floating point precision. If your planets are actually very large, and especially if they require detailed collision with objects much smaller than themselves, you will most likely encounter some inaccuracies and oddities. There's ways to deal with the issues that arise depending on what you're trying to accomplish.
- Attachments
-
- SphereGravity.zip
- (919 Bytes) Downloaded 605 times
Re: Planetary gravity
Following up on this thread.
In addition to the planet gravity, is there an easy way to attract some entities and having them always facing upwards?
I want this mainly for characters, so in the event they got attracted they can be standing on their feet.
Many thanks in advance!
Misscelan
In addition to the planet gravity, is there an easy way to attract some entities and having them always facing upwards?
I want this mainly for characters, so in the event they got attracted they can be standing on their feet.
Many thanks in advance!
Misscelan
Re: Planetary gravity
It's not too hard to compute an angular velocity or torque to orient an entity- the EntityRotator convenience class could help there. If you don't want full angular control, but instead just 1DOF upright control, you could use logic similar to the internals of the EntityRotator's angular velocity computation, except only work around one axis. The cross product between the current entity up vector and the desired up vector would be useful for this.
Applying that to a CharacterController's body would be trickier, though. The implementation assumes a fixed up axis. It can be modified to use a varying up direction, but that will take some work and fiddling with the CharacterController's different pieces.
Applying that to a CharacterController's body would be trickier, though. The implementation assumes a fixed up axis. It can be modified to use a varying up direction, but that will take some work and fiddling with the CharacterController's different pieces.
Re: Planetary gravity
Thanks for the quick reply!