import bge
controller = bge.logic.getCurrentController()
own = bge.logic.getCurrentController().owner
What are the python codes for this things:
Set/Get Location
#set location for local
own.localPosition = [0.0,1.0,2.0]
#get local location doesnt exist
#set location in world
own.worldPosition = [0.0,1.0,2.0]
#get world location
pos = own.position
Set/Get Rotation
#set rotation for local
own.localOrientation = [[0.0,1.0,2.0],[0.0,1.0,2.0],[0.0,1.0,2.0]]
#get local orientation doesnt exist
#set rotation world
own.worldOrientation = [[0.0,1.0,2.0],[0.0,1.0,2.0],[0.0,1.0,2.0]]
#get world rotation
ori = own.orientation
Set/Get Scale
#set scaling for local
own.localScale = [0.0,1.0,2.0]
#get local scaling doesnt exist
#set scalingin world
own.worldScale = [0.0,1.0,2.0]
#get world scaling
scale= own.scaling
The API reference is a great place to find the appropriate properties/methods your looking for. For help on converting 2.49 scripts to 2.5, you can take a look at this:
Thx,for the help guys, i gonna check that out and imrovedit my post, so anyone will faster know how to. Because i see this API right now more as a giant wall of text , that is usefull once you have reache your destination, but otherwise you kinda lost a bit.
Use the search function. I don’t even know 1% of the total Api, but i can find what i need just searching. And now many names are predictable. Mostrly you will need KX_GameObject and KX_Scene. Look at the functions in this classes and 80% of your problems will be gone
sorry, change .worldPosition and .worldOrientation for .position and .orientation, they are both the same but .position is newer
i think its the newest code.
I thought the other API are newer.
position
Description:The object’s position. [x, y, z] On write: local position, on read: world position
Deprecated since version use: localPosition and worldPosition.
Type : mathurils.Vector
orientation
Description:The object’s orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector. On write: local orientation, on read: world orientation
Deprecated since version use: localOrientation and worldOrientation.
Type : mathutils.Matrix
scaling
Description:The object’s scaling factor. [sx, sy, sz] On write: local scaling, on read: world scaling
Deprecated since version use: localScale and worldScale.
Type : mathutils.Vector