RectTileMapComponent

Provides a rectangular tile map function.

# Properties

[{"index":"Vector2 GridSize (Sync)","0":"The size of the grid."}]

[{"index":"boolean IgnoreMapLayerCheck","0":"Does not perform automatic substitution when the Map Layer's name is specified in SortingLayer."}]

[{"index":"boolean IsOddGridPosition","0":"Positions the tilemap off of the grid's base point."}]

[{"index":"int32 OrderInLayer (Sync)","0":"Determines the priority within the same Layer. A greater number indicates higher priority."}]

[{"index":"boolean PhysicsInteractable (ReadOnly)","0":"If true, it may collide with a Dynamic rigid body (PhysicRigidbody) using the Physics feature."}]

[{"index":"string SortingLayer (ReadOnly)","0":"When two or more Entities overlap, the priority is determined according to the Sorting Layer."}]

[{"index":"int32 TileCount (ReadOnly) (HideFromInspector)","0":"Total number of tiles currently placed."}]

[{"index":"string TileSetRUID (Sync)","0":"The RUID of the tileset."}]

##### 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":"void BoxFill(int32 tileIndex, Vector2Int from, Vector2Int to)","0":"Places tiles in a quadrangle area from \"from\" to \"to\". tileIndex is the index number of the tile."}]

[{"index":"void BoxFill(string tileName, Vector2Int from, Vector2Int to)","0":"Places tiles in a quadrangle area from \"from\" to \"to\". tileName is the Name property of the tile."}]

[{"index":"void BoxRemove(Vector2Int from, Vector2Int to)","0":"Removes tiles in the quadrangle area \"from\" to \"to\"."}]

[{"index":"void Clear()","0":"Removes all tiles."}]

[{"index":"List GetAllTilePositions()","0":"Returns a list of all tile locations in the current tilemap."}]

[{"index":"RectTileInfo GetTile(int32 cellPositionX, int32 cellPositionY)","0":"Returns the tile information at the corresponding location."}]

[{"index":"RectTileInfo GetTile(Vector2Int cellPosition)","0":"Returns the tile information at the corresponding location."}]

[{"index":"void RemoveTile(int32 cellPositionX, int32 cellPositionY)","0":"Removes the tile at the corresponding location."}]

[{"index":"void RemoveTile(Vector2Int cellPosition)","0":"Removes the tile at the corresponding location."}]

[{"index":"void Reset()","0":"Resets tile map to the initial state."}]

[{"index":"void SetTile(int32 tileIndex, int32 cellPositionX, int32 cellPositionY)","0":"Places the tile in the corresponding location with tileIndex being the index number of the tile."}]

[{"index":"void SetTile(int32 tileIndex, Vector2Int cellPosition)","0":"Places the tile in the corresponding location with tileIndex being the index number of the tile."}]

[{"index":"void SetTile(string tileName, int32 cellPositionX, int32 cellPositionY)","0":"Places the tile in the corresponding location with tileName being the Name property of the tile."}]

[{"index":"void SetTile(string tileName, Vector2Int cellPosition)","0":"Places the tile in the corresponding location with tileName being the Name property of the tile."}]

[{"index":"Vector2Int ToCellPosition(float worldPositionX, float worldPositionY)","0":"Converts the coordinates of real number world space to those of integer tile map space."}]

[{"index":"Vector2Int ToCellPosition(Vector3 worldPosition)","0":"Converts the coordinates of real number world space to those of integer tile map space."}]

[{"index":"Vector3 ToWorldPosition(int32 cellPositionX, int32 cellPositionY)","0":"Converts the coordinates of integer tile map space to those of real number world space."}]

[{"index":"Vector3 ToWorldPosition(Vector2Int cellPosition)","0":"Converts the coordinates of integer tile map space to those of real number world space."}]

##### 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."}]

# Events

[{"index":"OrderInLayerChangedEvent","0":"This event occurs when changing the Component's OrderInLayer."}]

# Examples

This is an example where player movement speed changes depending on the tile stepped on.
    
    
    @Component
    script TileSpeedModifier extends Component
        @ExecSpace("ClientOnly")
        method void OnUpdate()
        if _UserService.LocalPlayer ~= self.Entity then
        	return
        end
    
        local transform = self.Entity.TransformComponent
        local movement = self.Entity.MovementComponent
        local tilemap = self.Entity.CurrentMap:GetFirstChildComponentByTypeName("RectTileMapComponent")
    
        local worldPos = transform.WorldPosition
    
        -- Convert the world space coordinates to TileMap space coordinates
        local cellPos = tilemap:ToCellPosition(worldPos)
    
        -- Inquire about tile information in the currentLocation
        local tileInfo = tilemap:GetTile(cellPos)
    
        if tileInfo == nil then
        	return
        end
    
        if (tileInfo.Name == "Fast Tile") then
        	movement.InputSpeed = 2.4
        elseif (tileInfo.Name == "Slow Tile") then
        	movement.InputSpeed = 1.2
        end
        end
    end
    

# SeeAlso

  * MovementComponent
  * TransformComponent
  * UserService
  * [Creating Maps with SideViewRectTile Mode](/docs?postId=758)
  * [Utilizing RectTileMap](/docs?postId=589)