My element with width=200,height=200,pivotX=0.5,pivotY=0.5.
In the editor , the entity’s position is (100,100,0), at the left bottom of screen.
But in the script use getPosition(), it got vec3={x: -0.8276084661483765,y: -0.650456428527832, z: 0}
My element with width=200,height=200,pivotX=0.5,pivotY=0.5.
In the editor , the entity’s position is (100,100,0), at the left bottom of screen.
But in the script use getPosition(), it got vec3={x: -0.8276084661483765,y: -0.650456428527832, z: 0}
Hi @Tidus,
getPosition()
will return the world position of an entity. What you are looking in the editor in the inspector panel is the local position.
Try using getLocalPosition()
instead.
https://developer.playcanvas.com/en/api/pc.Entity.html#getLocalPosition
Thanks, i always forget it…