TransformComponent

Indicates the location, rotation, and the size of an entity.

# Properties

[{"index":"Vector3 Position (Sync)","0":"Shows coordinates relative to an Entity's parent."}]

[{"index":"Quaternion QuaternionRotation (Sync) (HideFromInspector)","0":"Shows the rotation value of the Entity as a Quaternion."}]

[{"index":"Vector3 Rotation","0":"Represents the rotation value of the Entity in Euler angles. In 2D, rotate using the Z axis. Synchronized by QuaternitonRotation."}]

[{"index":"Vector3 Scale (Sync)","0":"Represents the size ratio of the Entity."}]

[{"index":"Vector3 WorldPosition","0":"Represents the world-related coordinates of an Entity."}]

[{"index":"Vector3 WorldRotation (HideFromInspector)","0":"Represents an Entity's world-related rotation value in Euler angles."}]

[{"index":"float WorldZRotation","0":"Represents the value of the Z axis among the Euler angle rotation values based on the Entity's world."}]

[{"index":"float ZRotation","0":"Represents the Z-axis value among the Euler angle rotation values of the Entity."}]

##### inherited from Component:

[{"index":"boolean Enable (Sync)","0":"Checks whether Component is activated or not."}]

[{"index":"boolean EnableInHierarchy (ReadOnly) (HideFromInspector)","0":"Displays whether this Component is Enable in the hierarchy. If Entity Enable is false regardless of Component Enable, returns false."}]

[{"index":"Entity Entity (ReadOnly)","0":"The Entity that owns this component."}]

# Methods

[{"index":"FastVector3 PositionAsFastVector3()","0":"Change the Position value to a FastVector3 type."}]

[{"index":"void Rotate(float angle)","0":"Rotate this Entity counterclockwise by angle."}]

[{"index":"Vector3 ToLocalDirection(Vector3 worldDirection)","0":"Converts the direction entered from world coordinates to local coordinates. It is not affected by scale or position."}]

[{"index":"Vector3 ToLocalPoint(Vector3 worldPoint)","0":"Converts world coordinates entered to local coordinates. It is affected by scale."}]

[{"index":"Vector3 ToWorldDirection(Vector3 localDirection)","0":"Converts the direction entered from local coordinates to world coordinates. It is not affected by scale or position."}]

[{"index":"Vector3 ToWorldPoint(Vector3 localPoint)","0":"Converts local coordinates entered to world coordinates. It is affected by scale."}]

[{"index":"void Translate(float deltaX, float deltaY)","0":"Move the coordinates of this Entity by deltaX, deltaY."}]

[{"index":"FastVector3 WorldPositionAsFastVector3()","0":"Change the WorldPosition value to a FastVector3 type."}]

##### inherited from Component:

[{"index":"boolean IsClient()","0":"Returns whether the current execution environment is a client or not."}]

[{"index":"boolean IsServer()","0":"Returns whether the current execution environment is a server or not."}]

# Examples

The following is an example of rotating an Entity at a constant speed using the ZRotation property.
    
    
    @Component
    script Spinner extends Component
        property number AngularSpeed = 360
    
        @ExecSpace("ServerOnly")
        method void OnUpdate(number delta)
        local transform = self.Entity.TransformComponent
        local zRotation = transform.ZRotation
    
        transform.ZRotation = zRotation + (self.AngularSpeed * delta)
        end
    end
    

If you write the code with the same operation using the Rotate function, it should be as follows:
    
    
    @Component
    script EntityRotator extends Component
        property number AngularSpeed = 360
    
        @ExecSpace("ServerOnly")
        method void OnUpdate(number delta)
        local transform = self.Entity.TransformComponent
    
        transform:Rotate(self.AngularSpeed * delta)	
        end
    end
    

The following example makes an entity free fall. Use the Translate function and delta to move the Entity by the current speed.
    
    
    @Component
    script GravityMovement extends Component
        property Vector2 Gravity = Vector2(0,-9.8)
        @Sync
        property Vector2 CurrentVelocity = Vector2(0,0)
    
        @ExecSpace("ServerOnly")
        method void OnUpdate(number delta)
        local transform = self.Entity.TransformComponent
    
        self.CurrentVelocity = self.CurrentVelocity + (self.Gravity * delta)
    
        local deltaX = self.CurrentVelocity.x * delta
        local deltaY = self.CurrentVelocity.y * delta
    
        transform:Translate(deltaX, deltaY)
        end
    end
    

# SeeAlso

  * Vector2
  * [Changing Location, Size, and Rotation of Entities](/docs?postId=82)