I can’t belive that my project has to wait because I have a problem with
the compass…
I made a example of my problem and here it is: http://www.zone.ee/xintest/compasstest.blend
The compass doesn’t move right so please tell me what’s wrong… I know
it’s my mistake…
Personally, i like to put this kind of thing in an overlay scene. I’ve tweaked your .blend so it works, the compass is in a new scene called ‘compass’ ;), now the script works, but this may not be what you want…
The only problem I see with that compass is that it is working opposite to how a compass would work in real life when turning left or right. If you start the game you are facing north. If I turn the cube slightly to the left the compass should point slightly to the right. The way it’s set up right now it’s just moving the exact same way as the cube which isn’t how a compass works. As you turn away from the north (either right or left) the compass needle should point the opposite direction that the cube is turning.
I assumed the needle was supposed to indicate the cubes direction, that’s how the script’s set up, rather than north, but if you want a ‘real’ compass it’s pretty simple. Just change the script that set’s the needles orientation to:
own = GameLogic.getCurrentController().getOwner()
ori = GameLogic.ori
ori[0] = [-ori[0][0], -ori[0][1], -ori[0][2]]
ori[2] = [-ori[2][0], -ori[2][1], -ori[2][2]]
own.setOrientation(ori)
This flips the X and Z axis, giving a mirror image essentially. Note: you don’t really need to flip the Z for it to work, I just did it anyway and also you’ll need to turn the needle mesh upside down to see it.
cheers
Piran
PS - to the great python guru’s, if theres a simpler way to negate the elements in the list please point it out