I think I have found a little bug. KX_GameObject.setPosition() thinks in LOCAL coordinates, while KX_GameObject.getPosition() returns GLOBAL coordinates. I checked the 2.45 sources and I think this is the case.
Could you provide an example? I tested it, but didn’t find any bugs.
I’ve never experienced this problem with getPosition() and setPosition(). However, if it truly does work as you say, it’s not a bug. It was programmed that way intentionally. getOrientation() and setOrientation() work the same way.
Two objects do not necessarily share local values in common, so if you wanted to copy the rotation of one object to another object, you would need to get the first object’s global rotation. I think the problem is that the Game Engine is then applying transformations locally, so it interprets the value you give it in setOrientation() as a local rotation. I don’t know why this is, though (was it necessary? what led the programmers to program it this way?).
With getOrientation() and setOrientation(), you can translate the global values to a local value using matrix multiplication, but I’d rather not have to do that personally. I would much prefer it if the two were both global.
A simple example would be two objects, one parent of the other. Give some non-trivial geometric transform to the parent (rotate, translate and scale by some amount), and try child.setPosition§. You will see that p != child.getPosition() after that. I don’t think that was the intention. Documentation say they both work in World coordinates.
Ah. I see. Since the problem is specifically related to parenting, and getPosition() and setPosition() work as expected otherwise, I’d say you have a parenting bug on your hands.
This is probably the parenting bug that popped up in 2.44. For exmaple, if you try using “Edit Object >> Track To” Actuator on a child object, it does not perform as expected (the transformations are off, including rotation and location). At least, I know that’s the case with vertex parenting. Haven’t tried it with standard parenting yet.
You may want to make some working examples of the bug and submit them to the Game Engine coders. I don’t think that this bug has been shown to them and traced down, so the more info you could provide them, the better the chance it will be fixed by the next release.
Edit: I forgot to mention. Until then, you can mimic parenting by using an Always sensor hooked to a script that constantly copies the location and rotation of the parent. I was forced to resort to this solution for my current Sokoban project.