the Perfect Position

hi, i need help with setting the position of an object using python
i want to set ONLY the Z position, i want to leave the X and Y positions COMPLEATLY alone

i already tried,

pos=owner.getPosition()
owner.setPosition((pos[0],pos[1],N))

where " N " is my new z position,

this doesn’t work because it messes with movement of the object on the x and y axies

does anything like " setZPosition() " exist?

tha

Haven’t time to test this right now, but I think it’s

owner.setPosition()[2] = N

[1] would be for the Y-axis, [0] for the X-axis.

i just tried it and got the error message " function takes exactly 1 argument <0 given> "

try

pos = own.getPosition()
pos[2] = (your variable)
own.setPosition(pos)

Maybe this will work:

owner.setPosition(o.getPosition()[0],o.getPosition()[1],N)

the script didn’t work, but thanks for the reply
the " setPosition(pos) " still set the values of x and y

i’m guessing what i want to do doesn’t exist. i have a workaround way to do it, but i would still prefer to do it another way

thanks again for the replys :slight_smile:

HOLD IT! i tested my script. it dose not move the x or y values. maby they are being moved by another part of your game. OH! maby you want to move the Y axis! blender (for some reason) switched the Y and Z axises. i can’t see what else could be wrong. unless you post a .blend, than I could fix it for you.

Yes, getPosition() returns a list and setPosition takes a list. So


pos = o.getPosition()
pos[2] = num
o.setPosition(pos)

should do it. The first way you wanted would have worked too.

There is something else modifying the x and y positions, or you are confused about which value you actually want to set. If you are playing any ipos at the same time, this could conflict.

hey Andy83,

it worked, thanks a ton
i’m guessing it worked because the position was taken while it was being set

my script had more to it than just setting the z position, that’s why the other way’s didn’t work(velocity was applied before and sometimes after the setting of the z position)

thanks again