I’m really confused with the API at this point. I have read though
- Blender/Python Quickstart: new to blender/scripting and want to get your feet wet?
- Blender/Python API Overview: a more complete explanation of python integration
- Blender/Python Addon Tutorial: a step by step guide on how to write an addon from scratch
- Blender/Python API Reference Usage: examples of how to use the API reference docs
- Best Practice: Conventions to follow for writing good scripts
- Tips and Tricks: Hints to help you while writing scripts for blender
- Gotcha’s: some of the problems you may come up against when writing scripts
and it even says in there
Being an API reference, this link often gives little more information then the tool-tip, though some of the pages include examples (normally at the top of the page).
My problem is for example
bge.logic.getCurrentController().owner.worldPosition.x +=1
I can see this code moves the object in the x direction by 1 blender unit.
However if I go on the blender API reference and search for worldPosition it will show
- bge.types.KX_GameObject.worldPosition (Python attribute, in Game Types (bge.types))
- Game Types (bge.types)
then when I click on the first one it takes me to
worldPosition
The object’s world position. [x, y, z]
[TABLE=“class: docutils field-list”]
[TR=“class: field-odd field”]
[TH=“class: field-name”]Type :[/TH]
mathutils.Vector
[/TR]
[/TABLE]
If it were not for
bge.types.SCA_PythonController
cont = bge.logic.getCurrentController()
bge.types.KX_GameObject
obj = cont.owner obj.worldPosition.z += 1
I would have never have known that the above is the correct way to call the function.
The world position API only says
worldPosition
The object’s world position. [x, y, z]
[TABLE=“class: docutils field-list”]
[TR=“class: field-odd field”]
[TH=“class: field-name”]Type :[/TH]
mathutils.Vector
[/TR]
[/TABLE]
which would make me think you would enter it in as ~foo.bar.worldPosition[1,1,1] or somthing.
Does the API assume I know how a given function is supposed to be used? So I guess my question is really
what am I doing wrong here? Am not interpreting the information in the API correctly and if so,
Where can I get information that can show me how worldScale for example is supposed to be used or
how I can get that infromation by understanding the API better.
Like I said I’m just confused at this point and don’t know where else to turn so I’m hoping someone
is able to provide a sound explanation for me so I can move forward. Thanks for reading. Peace