Custom gravity?

Is there a way to make custom gravity in a game? Like Mario Galaxy or just changing how strong the gravity is.

during the game you have to use Python. Outside the game go to the world buttons and find gravity then change it.

Ok so how would I do it with Python?

I think

gamelogic.setGravity(number)

I believe that will work.

Ok so how would I make so that every time you press a button the gravity increases by a certain amout? Same with decreasing.

And do I need to put something before that? I’m really new to Python.

let me test it ad upload a blend.

EDIT never mind I can’t seem to get it to to getSensor(“anysensor”)

Ok well thanks for trying.

i’ll make a demo for you

The GameLogic.setGravity() function actually takes in a list like: [x,y,z].
Normal gravity is [0,0,-9.4], to make that work type GameLogic.setGravity([0,0,-9.4].
Making gravity weaker would be moving -9.4 closer to 0 and 9.4 would actually make gravity go up. You can even make gravity go to the left with [0,-9.4,0] or if you want to get tricky upwards-left [0,-9.4,9.4].

I made a prototype game some time ago, it was a maze where you had to change gravity in order to solve it.

You have given me an idea and for the sake of it I’m going to try make a demo like mario galaxy where you can walk around a sphere. Unless thats noob destroyers demo.

Ok thanks.

Whether you use setGravity() or you have the character track to the nearest object and apply a constant “downwards” force, you’ll need to have some matrix editing in the file somewhere to figure out how to make things point. So it’s not very easy at all.

By the way, standard gravity is 9.8, not 9.4.

Oops, my mistake :o

It ain’t anything pretty but it’s just to show you how you would do it. Press up arrow to add 1 to gravity and down arrow to subtract 1 from gravity. You’ll understand when you use it:p
Add in a few extra dynamic objects if you want but remember to enable “no sleeping” otherwise it may not work properly.

Attachments

gravity.blend (128 KB)

Ok cool thanks.