Problem with position changing

Hi

I can not figure out what is the problem.
I do ob.position[1] += somevalue, but but both ob x and y position values are changed.
Why?

Attachments

scroll_problem.blend (682 KB)

I think using object.position is depreciated, (Why? I don’t know.)
anyway it works if you use localPosition or worldPosition.

as far as I know(and i might just not know.) object.position was never anything…I always either used object.setPostion or object.world/localPosition.

Oh I just relized that you were having a problem…sorry… umm you have to add the value in the list.
example:

pos = object.worldPosition
object.worldPosition = [pos[0],pos[1] + 1,pos[2]]

if that helps…

Hello guys,

To clear things up: position is nit deprecated, opposite to setPosition.
Anyway position is not working, opposite to localPosition and worldPosition.
If anyone could explain to me what is position for, and why it is working so weird in my script,
I’d be grateful.

OK…

First, just for the record: GameTypes.KX_GameObject-class.html#position
sometimes its hard to keep track of all the crazy changes : )

Now, to explain your problem lets go back to the original methods.
setPosition()
setWorldPosition()
getPosition()

If you read the descriptions you may have figured out that setPosition sets the objects position in Global coordinates, but if the the object is a child of another object,(as in your example) then the object is moved in Local coordinates.

So in your case, you’re getting the position e.g. [2,5,0] (world position)
you want the object to move down the y-axis so you subtract 2, = [2,3,0]

Setting the objects local position(which should be [0,0,0]) to [2,3,0] results in the object moving up 3 and over 2.
That’s why you use worldPosition.

IMHO the methods are easier to understand and work with than variables,
and shouldn’t be deprecated. And neither should “object.someProperty”.