Skip to main content

Scripting

Scripting in Unity uses C# and is very well documented. In the sections below, I'll Provide examples and edge cases where possible, and link to the relative documentation for quick reference.

For a collection of classes and structs that are required for Unity to function, which means they will always be available to you when scripting in Unity, head over to UnityEngine.CoreModule Documentation

Transform

This class controls and tracks object position, rotation, scale.

Official Transform Class Documentation

Local Space

Local space is the transform relative to the object's parent. An example of this can be seen below where I have selected an object and the transform controls are centralized on the exact transform of that object relative to its local position.

Take notice of three things in the above screenshot. First, we have selected Local position in the top-left near our transform controls. Clicking this button again will toggle between Local and World space. Second, take note of the World Space axis shown at the top-right of the scene view. Third, in contrast to the World space axis, notice the GameObject's axis shown in the scene view are different in orientation. The transform axis shown on the GameObject are modifying and referring to the GameObject's transform within Local space.

World Space

World space is the combination of the GameObject and its parent positions rooted within the scene. An example of this is seen in selecting the exact same object in the editor and toggling world space transform view. This makes sure the transform controls are the same as the World Space axis, instead of referring directly to the transform of a local object.

Again, take notice of three things in the above screenshot. First, we have selected Global position in the top-left near our transform controls. Clicking this button again will toggle between Local and World space. Second, take note of the World Space axis shown at the top-right of the scene view. Third, in contrast to the World space axis, notice the GameObject's axis shown in the scene view are different in orientation. The transform axis shown on the GameObject are modifying and referring to the GameObject's transform within World space.

Vector3

Official Vector3 Struct Documentation

Quaternion

Official Quaternion Struct Documentation