How to set an object to rotate or move according to its own coordinate system

Hello, I’m a programmer from Malaysia!It’s my first time to use PlayCanvas!I want to set a three-dimensional coordinate to an object and let the object move to this coordinate. But the coordinate system seems to be the world coordinate system. Is there any way to change it to the object’s own coordinate system?I know that there are setPosition and setLocalPosition in the API document,But I’m not sure what is the difference between the two.I hope someone can help,thx

Hi @ashaaaaaaa and welcome,

Indeed PlayCanvas uses two coordinates systems to handle entity translation/rotation, world and local. Both uses three axis (X, Y and Z).

World axis are always the scene world X,Y and Z axis.

Local axis is a second system that allows an entity to have its own local translation/rotation, quite useful to position and rotate an entity in relation to its parent entity.

You can use the following button in editor to switch between these two systems and better visualize and work with each:

image

Hope that helps.

1 Like

I created a new object whose world coordinates and local coordinates are the same,Is there no difference between setPosition and setLocalPosition?

Local coordinates are always relevant to its parent entity. If the entity doesn’t have a parent entity, or if the parent entity is at 0,0,0 then you will see no difference.

Try moving its parent entity somewhere or rotate it, and then play with the local coordinates on the child entity.

okay,I’ll try it

Oh,Yes!Thank you for helping me solve this problem! :slight_smile:

1 Like