Fixing floating when walking down steep slope.

xanagan
Posts: 1
Joined: Tue Sep 11, 2012 8:37 am

Fixing floating when walking down steep slope.

Post by xanagan »

I modified the HelloWorld example to use capsule shape for walking character and triangle mesh for world.

All is working well except for the situation where the character walk off the cliff or walk down slope.

If I dont explicitly let up the joystick (set linear velocity to 0) the character will still walking on the air for a while.

If I raise the gravity of dynamic world to -50.0 the character can walk down some not too steep slope but the cliff and steep slope are still the problem.

Please suggest me a way to fix this problem.

The following are parameter use to create capsule
Shogo
Posts: 6
Joined: Tue Aug 07, 2012 3:27 am

Re: Fixing floating when walking down steep slope.

Post by Shogo »

Hello. Whitout knowing exactly how you are moving your character (with linear velocity or applying a force or whatever), I'll make some assumptions. Assuming it is with a linear velocity and the Y axis is up and down, then negative Y is the direction of gravity.
So for example if the moving forward direction of your character is given by

Code: Select all

btVector3 forwardDir = btVector3(0.0, 0.0, -1.0);
Would explain why when you not contacting the ground if you keep pressing the moving button (or joystick) your character keeps moving forward without "falling".

you could try to give your movement a component in the negative Y direction:

Code: Select all

btVector3 forwardDir = btVector3(0.0, Vy, -1.0);
You can try experimenting giving Vy some values. If you set it too high your character will "stick" to the ground and you wont be able to move lol, or if you have steps/stairs setting it too high might also keep you from climbing these stairs/steps.



/*
If you want to calculate that Vy value:
We know
Vy = Voy + g*t

Vy: velocity in Y direction
Voy: initial velocity in Y
g: gravity
t: time

If we make Voy=0 we would have
Vy=g*t;

g= whatever your gravity value is (-9.8 for earth)
t=time (you can use your stepsimulation time)
*/

Another thing you can do is to check if your character is touching the ground, if your character isn't touching the ground disable the players ability to keep moving your character (so that if they still pressing the key (or joystick) they can't keep moving forward) and let gravity take over.