blender, python, and me.

i was wondering, if i wanted to use python coding in blender, what would i use, regular python or python game (

i would like to change the direction the gravity moves when i press a button, so i looked in the python compiled html help log, found no gravity functions. so does BGE use pygame? or does blender have its own code base? i can’t seem to find a BGE compiled help log with all of its functions/descriptions. if there is one, can i have the link? (USA, windows xp)

thanks for the help.

hmm, thats the one i have.
theres no gravity direction changeing in blender?

i found this:

set the gravity to 10

GameLogic.setGravity([ 0.0, 0.0, -10.0])
but tht sets the intensity of the gravity.

Intensity dictates direction.

Try changing the numbers in the list being fed to setGravity(). For example, change the -10 to just plain 10.

Please run a few tests on your own next time before you needlessly waste forum space.

PS: Pygame is an external module set that could be used with the blender game engine (as could any other module set/python script). However, the BGE doesn’t require it. If you want to write python code that will trigger various events in the blender game space, you need to learn the BGE API - (the link Mico already provided is very good in that regard). Also, for starters, this might be a good tutorial to go through:

yes i know i can change the direction by changing the values. but for what i want the would get complicated.
see, i want the gravity to rotate from 1-360 (and loop back) the longer i hold a key (left/right)

i can’t just keep increasing/decreasing 1 axis, because that would just reduce the amount, i need it to ROTATE. i don’t know how i would increase/descrease values so the it acts normal. its hard to explain.
if you want a 2d example game (i made it in a program called “game maker”. only 3 levels. press F1 for help) here: (edit, yeah, lame graphics. but i was newb to GIMP at the time i made it)

i want to remake this in 3d w/physics. i rotated the gravity direction and camera, not the objects/gravity intensity

Just slow down for a sec and think about it…

How’s gravity represented in blender - A vector of 3 values.
How’s a point represented in 3d space - A vector of 3 values

How do you rotate a point in 3d space - with trig functions
How do you rotate the direction of the gravity vector in blender - with the very same trig functions.

If you wanna rotate around the X axis, you’ve gotta change Y & Z
similarly, a Y axis rotation implies a changing of the X and Z values, while a Z axis rotation necessitates the changing of X and Y components.

A different kettle of fish is when you want to rotate around some arbitrary axis, that isn’t parallel to X or Y or Z. But there’s plenty of code around for this too. Just have a look around - searching for 3d vector maths should get you the goods.

i’m not best in math. barly passed algebra 1. so i’m completely confused with trig.
i’m not on desktop so i can’t test ATM so imma get some facts strait so i can test when i can :slight_smile:
so if i want to rotate the x axis, i’m going to have to change the z/y intensity accordingly to get the rotation i want? i have never scripted for blender before so this will get confuse for me. any help appreciated.

This requires no math, but simply a basic understanding of how 3D works.

In 3D space, positions are defined by coordinates X, Y, and Z.

import GameLogic

X = 0.0 # The gravity along the X axis (right and left)
Y = 0.0 # Gravity along the Y axis (forward and backward)
Z = -10.0 # Gravity along the Z axis (up and down)

GameLogic.setGravity([X, Y, Z])

If you were to give X a positive value like 10.0, then there would be 10.0 gravity pulling right.

Give X a negative value like -10.0, then, you guessed it, there would be 10.0 gravity pulling left.

thank you very much.
i’m not working on this project untill i get my BGEpy down. i made a few game with code blocks, now i’m converting them for experience. i’ll get back to this later. thanks