Increase Gravity

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
nikolaiko
Posts: 43
Joined: Mon Aug 04, 2014 8:26 am

Increase Gravity

Post by nikolaiko » Fri Mar 06, 2015 6:15 am

Hi.

I am finishing with world physics setup, but I have one more problem to solve. How can I increase bodies falling down speed. It doesn't depends on mass (of course), so body with mass 400 and 2 falling down with same speed. I can't use AirSpeed and AirForce for this purpose (I guess). So, the only way - to increase gravity, problem is what bodies fall down fast enougth only with gravity value (0, -400, 0). In some posts a rad what you didn't recommend to play with gravity, especially maxing it so hight. And I saw why, during falling down bodies went half past earth mesh. Even then I raise TimeSteepDuration to 1/60 it doesn't help. So, maybe there are another ways to increase falling down speed?

Thanks.

Norbo
Site Admin
Posts: 4570
Joined: Tue Jul 04, 2006 4:45 am

Re: Increase Gravity

Post by Norbo » Fri Mar 06, 2015 6:56 pm

First, ensure that there is nothing interfering with gravity. For example, a couple of possible explanations:
1) Very high linear damping will sap linear momentum accumulated from gravity, making entities fall slower.
2) The engine is updated in slow motion, so it makes it look like gravity needs to be higher when the actual solution is simulating more simulation time per real time.

For reference, if 1 unit of length was 1 meter, 400 gravity would be ~40x earth gravity. That's substantially higher than even the Sun's surface gravity. Sanity check the simulation to make sure this is truly required.

That said, if you need faster falling, then increasing gravity is the way to do it. Any other method which accomplishes the same effect will cause the same problems anyway.

To compensate for tunneling, turn on CCD (entity.PositionUpdateMode = PositionUpdateMode.Continuous) and/or update more frequently with smaller time steps. A TimeStepDuration of 1/60 is the default value; you may need to push it to 1/120, 1/180, or even shorter for simulations with lots of fast interactions.

At these scales you'll probably also need to play with the tuning of the engine to improve the quality of the simulation, since it is unlikely that the default tuning is optimal for such an extreme simulation. You can use the BEPUphysicsDemos ConfigurationHelper.ApplyScale function to help do this.

nikolaiko
Posts: 43
Joined: Mon Aug 04, 2014 8:26 am

Re: Increase Gravity

Post by nikolaiko » Tue Mar 10, 2015 9:27 am

Thanks for the answer!

I changed TimeStepDuration (1/120) parameter and after that we were able to drop gravity value to -200 it is only 20x more then earth instead of 40x :) and looks like gravity working fine. But I found another thing. Looks like mass of the objects doesn't affect speed too much. Body with mass 4, 10, 20 can go with speed that I set initially. Quaestion is how fast they will reach the mark. But I want to emulate soome kind of overweight. For example, I have robot with mass 2 and speed 20. This robot have some places for different loot and items. And if I will start to load something where, robot mass will increase, but max speed must drop down (not only time of acceleration to max speed). So robot with bigger mass (with loot and items) will go slower then same robot with empty cargo's. Because, same engine can't move diffeerent weight's with same speed.

Is there any ways to do it using only engine physics, just increasing mass and let physics code to handle it? Or I must manually check mass everytime it changed and change StandingSpeed as well? Because, right now I found in code only one place wich really use speed value :

Code: Select all

if (SupportFinder.HasTraction)
                {
                    HorizontalMotionConstraint.MovementMode = MovementMode.Traction;
                    HorizontalMotionConstraint.TargetSpeed = StanceManager.CurrentStance == Stance.Standing ? standingSpeed : crouchingSpeed;
                    HorizontalMotionConstraint.MaximumForce = tractionForce;
                }
                else
                {
                    HorizontalMotionConstraint.MovementMode = MovementMode.Sliding;
                    if (StanceManager.CurrentStance == Stance.Standing)
                    {
                        HorizontalMotionConstraint.TargetSpeed = Math.Min(standingSpeed, slidingSpeed);
                        HorizontalMotionConstraint.MaximumForce = Math.Min(tractionForce, slidingForce);
                    }
                    else
                    {
                        HorizontalMotionConstraint.TargetSpeed = Math.Min(crouchingSpeed, slidingSpeed);
                        HorizontalMotionConstraint.MaximumForce = Math.Min(tractionForce, slidingForce);
                    }
                }
according to it mass of the charactercontroller's body doesn't affect speed at all.

Thanks.

nikolaiko
Posts: 43
Joined: Mon Aug 04, 2014 8:26 am

Re: Increase Gravity

Post by nikolaiko » Tue Mar 10, 2015 8:49 pm

Ok, I found material property, it looks like it can help implementing this kind of functionality (about different speed with different mass).

Norbo
Site Admin
Posts: 4570
Joined: Tue Jul 04, 2006 4:45 am

Re: Increase Gravity

Post by Norbo » Tue Mar 10, 2015 9:15 pm

I changed TimeStepDuration (1/120) parameter and after that we were able to drop gravity value to -200 it is only 20x more then earth instead of 40x :) and looks like gravity working fine.
Something sounds odd here- decreasing the time step duration should not make gravity appear stronger. If nothing else changed and gravity actually seemed stronger, there are probably other time stepping issues in play.

If you mean that 1/120 time step duration eliminated tunneling well enough that -200 gravity was usable, then that is more expected.
Is there any ways to do it using only engine physics, just increasing mass and let physics code to handle it? Or I must manually check mass everytime it changed and change StandingSpeed as well? Because, right now I found in code only one place wich really use speed value :
Mass has no physical effect on maximum speed. If you want to change the maximum speed, it must be set explicitly. (If you don't want to worry about the different character state specific speeds, you can just set the SpeedScale.)
Ok, I found material property, it looks like it can help implementing this kind of functionality (about different speed with different mass).
Characters do not obey friction by default. The character body is actually frictionless to allow it to slide along walls easily. The HorizontalMotionConstraint is the thing that actually makes the character move, and it obeys the StandingSpeed/SpeedScale etc. properties.

nikolaiko
Posts: 43
Joined: Mon Aug 04, 2014 8:26 am

Re: Increase Gravity

Post by nikolaiko » Wed Mar 11, 2015 7:03 am

Hi. I mean that I set TimeStepDuration to 1/120. And it removed tunneling with gravity -200. Things falling little bit slower then with -400 but not too much.
Thanks.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests