Local Space Vs. World Space in Unity

A fundamental concept of game engines that we use all the time.

Let’s start with the definition of coordinate space, it’s a system for describing the position of something. In our case in Unity, it is also used to specify the orientation and scale of objects in our scenes which are the three components of the Transform of a game object.

World space is the position of an object within the Unity scene. When you add an object in the scene you position it in the coordinate space and if you press “reset position” in the Inspector panel you bring it to the center of the scene.

change world position of the parent object

The local space instead is the space of an object with respect to another object. To explain better just take the example of a parent object, if you have an object related to another object above it pressing the “reset position” key you will not go to the center of the scene, but you will be at the center of the parent object. I would always be in the coordinate zero but with reference to a different space.

reset the position of child objects

Through the code, there are methods that allow you to switch from local space to world space and vice versa.

In my case, I used TransformDirection to switch from local space to world space. For all related methods I refer you to the API of Unity

project manager by day, unity developer by night