# Gravity question

Hello I got a question, in the game engine. What if you want the character to follow the ground, but not be affected by gravity when he goes up hill or down hill. Like he goes faster when he is going down a hill and slower when he goes up a hill. But he still jumps according to the gravity.

In the image, the cube goes up the hill inside the room. And stops in the middle, then he slowly falls down again. How can you make him not fall down?? If you don’t understand tell me because my english is limited.

Thanks

you would have to use python I assume.

Really, isn’t it possible without scripting. Isn’t there anyone who has done this before who could tell me how you do this??:eek: It’s just like in platformers like spyro crock crash bandicoot etc…Or if scripting is the only way, maybe you could give me the script thanks for your cooperation :rolleyes:

hmmmm… This has been my biggest problem thus far… I don’t have a solution and therefore cannot help you, sorry

oh wait world buttons gravity make it zero then poof no gravity.

What? No I want gravity, I just don’t want it to affect the character while he is in the middle of a hill…and there seems to be more people who got this problem. Where are the pro blender users!

If you only want gravity when the char and is in midair have a a property that when true makes a actuator trigger with a -9.4 Z force and turn gravity off in the world buttons.

Is it really that simple, sorry but I’m very new to logic briks. And I have no idea how to do what you just said. Please make a blend file please please

http://www.box.net/shared/o0au7za0sh

Space for making it go up into the air… And then wait for it to fall down… XD

I got a small problem with that blend file. I made a hill, but still gravity affects the cube while it stops in the middle of the hill…maybe u misunderstood what my problem is :eek:

I’l try to explain again, ok we got a hill…it’s facing maybe 40 degrees or something. Now the cube is going up hill. And stops in the middle of the hill. Now I want it to stay there, but the gravity makes the cube go down hill again. Now I canät explain it better than that. You understand?

Yes, but in my example it shouldn’t be moving if in the middle of a hill? Damn I’ll try again… XD

make the hill a property “earth” I believe by looking at his .blend

What exactly do you mean? Is his blend file actually working?? Tell me how…

ok yes it does work. Make your hill then in the game logic hit add property and name it earth I think this will work.

Alright James XVI it works thanks a lot man. :eyebrowlift:

Physics lesson time! If you want to skip the physics, a solution to your problem is under this section:

When objects are pressed against something (like when an object is “pressed” against the ground by gravity) that something (ie, the ground) exerts a force back called the “normal force.” This is why objects don’t fall through the ground. The normal force is basically perpendicular to the surface (see attached image).

For example, when a ball is just laying on the ground, the force of gravity and the normal force are equal, therefore the ball doesn’t move.

The reason your object “slides” on slopes is because the force of gravity is creating a normal force that isn’t straight back up, but is perpendicular to the ground. Since there’s no force to counter-act the horizontal part of that “diagonal” force, your object
starts to slide. Not as fast as gravity, but pretty fast.

Friction is usually what keeps objects on slopes from sliding down. The force of friction is related to the normal force.

The way to stop your object from sliding is to give your ground a large enough amount of friction to counter-act the normal force. You can do that by assigning a material to the ground object, clicking the “DYN” button, and then cranking up the friction.

If you’re using Force to move your character, this will make it more difficult for your character to move up the slope, and he’ll probably go up it slower. I’d recommend using the Servo motion controls, they’ll give you a better result anyways.

Let me know if you have any questions

-Sam

### Attachments

Increasing the friction actually worked! Thanks alot that is exactly the effect I wanted. And now I can do it myself. Btw just a quick little question. How do you clear a rotation…and is there some kind of guide for all the shortcuts in blender like.

Shift + D - copy
s - size

etc…that would be very useful…:yes:

Raider solved this problem for me with one of his great scripts, you can check it in here http://www.gameblender.org/viewtopic.php?f=20&t=81 , hope it helps .

You don’t need any scripts, just increase the friktion of the hill…

Increasing the friction will prevent the character from climbing too, am I wrong?