can i setPosition JUST the y axis?

hi… i wanna setPosition my object in gameblender… but i JUST want to change the Y axis, and leave the x and z axis alone…
is there a way to do this?

like:
own.setPositionY(5) as an example of exactly what i want

i can type “print own.getPosition()[1]” and sure enough it prints out the Y position for me, but cant get it to work with setPosition
please please dont tell me its impossible… im oh so close on this one script :slight_smile:

and also, orientation is so weird… could someone explain it to me?
getOrientation prints out soemthing like:
[[1,0,0], [0,1,0],[0,0,1]]

why is orientation a list of three lists? i was expecting X,Y,Z just like position… as of now im blindly using getOrientation before i use setOrientation to set the right rotation i want, but am still a little confused at why theres three lists in a list
thanks

try something like this


own.setPosition(own.getPosition()[0], 5, own.getPosition()[2])

asuming “own.setPosition(x, y, z)” is the usual syntax.

as for getOrientation, that looks a lot like a rotation matrix.
Each line in a rotation matrix is a vector representing an axis. Each vectors are perpendicular to the two others. (a good 3D representation of that would be an Empty).
Rotation matrices are represented in Python by a list of three vectors.

I hope that’s useful. I have never used the game engine API, so don’t take all what I just said for granted.

Martin

yay it worked thank u!
i actually tried that idea before, but seeing your code in writing made me think "he forgot to put list brackets around that setPosition value =D then that made me realize i forgot to do the same thing!! i was wondering why it went all buggy on me… haha

im still a tiny little confused about the orientation, but i think i know what your talking about now =D thanks for explaining

More than you want to know on the rotation matrix:
http://www.makegames.com/3drotation/