setting one axis


i have a qeustion, how can is set one axis with the setPosition method/function. I only want to set the Z-axis.

//but now they have all three a value so i only want to give the Z-axis

caus with the getPosition you can do: x = cont.getPositon()[0] but with setPosition this doenst work…

thanks for your time!

pos = obj.worldPosition
pos[2] = theValueYouWant
obj.worldPosition = pos

I hope it helps

Just a little correction to what Monster said, hope he doesn’t mind.

According to the API, it is recommended that you use obj.localPosition to set the location, and obj.worldPosition to get it.

pos = obj.worldPosition
pos[2] = theValueYouWant
obj.localPosition = pos

Always just trying to help. :wink: