Table of Contents

Class TileData

Settings for a single tile in a TileSet.

Inheritance
TileData

Remarks

TileData object represents a single tile in a TileSet. It is usually edited using the tileset editor, but it can be modified at runtime using TileMap._tile_data_runtime_update.

Properties

flip_h

If true, the tile will have its texture flipped horizontally.

var flip_h : bool = false

Property Value

bool

Remarks

  • void set_flip_h(bool value)
  • bool get_flip_h

flip_v

If true, the tile will have its texture flipped vertically.

var flip_v : bool = false

Property Value

bool

Remarks

  • void set_flip_v(bool value)
  • bool get_flip_v

material

The Material to use for this TileData. This can be a CanvasItemMaterial to use the default shader, or a ShaderMaterial to use a custom shader.

var material : Material

Property Value

Material

Remarks

modulate

Color modulation of the tile.

var modulate : Color = Color(1, 1, 1, 1)

Property Value

Color

Remarks

  • void set_modulate(Color value)
  • Color get_modulate

probability

Relative probability of this tile being selected when drawing a pattern of random tiles.

var probability : float = 1.0

Property Value

float

Remarks

  • void set_probability(float value)
  • float get_probability

terrain

ID of the terrain from the terrain set that the tile uses.

var terrain : int = -1

Property Value

int

Remarks

  • void set_terrain(int value)
  • int get_terrain

terrain_set

ID of the terrain set that the tile uses.

var terrain_set : int = -1

Property Value

int

Remarks

  • void set_terrain_set(int value)
  • int get_terrain_set

texture_origin

Offsets the position of where the tile is drawn.

var texture_origin : Vector2i = Vector2i(0, 0)

Property Value

Vector2i

Remarks

transpose

If true, the tile will display transposed, i.e. with horizontal and vertical texture UVs swapped.

var transpose : bool = false

Property Value

bool

Remarks

  • void set_transpose(bool value)
  • bool get_transpose

y_sort_origin

Vertical point of the tile used for determining y-sorted order.

var y_sort_origin : int = 0

Property Value

int

Remarks

  • void set_y_sort_origin(int value)
  • int get_y_sort_origin

z_index

Ordering index of this tile, relative to TileMap.

var z_index : int = 0

Property Value

int

Remarks

  • void set_z_index(int value)
  • int get_z_index

Methods

add_collision_polygon(int)

Adds a collision polygon to the tile on the given TileSet physics layer.

void add_collision_polygon(int layer_id)

Parameters

layer_id int

add_occluder_polygon(int)

Adds an occlusion polygon to the tile on the TileSet occlusion layer with index layer_id.

void add_occluder_polygon(int layer_id)

Parameters

layer_id int

get_collision_polygon_one_way_margin(int, int)

Qualifiers: const

Returns the one-way margin (for one-way platforms) of the polygon at index polygon_index for TileSet physics layer with index layer_id.

float get_collision_polygon_one_way_margin(int layer_id, int polygon_index)

Parameters

layer_id int
polygon_index int

get_collision_polygon_points(int, int)

Qualifiers: const

Returns the points of the polygon at index polygon_index for TileSet physics layer with index layer_id.

PackedVector2Array get_collision_polygon_points(int layer_id, int polygon_index)

Parameters

layer_id int
polygon_index int

get_collision_polygons_count(int)

Qualifiers: const

Returns how many polygons the tile has for TileSet physics layer with index layer_id.

int get_collision_polygons_count(int layer_id)

Parameters

layer_id int

get_constant_angular_velocity(int)

Qualifiers: const

Returns the constant angular velocity applied to objects colliding with this tile.

float get_constant_angular_velocity(int layer_id)

Parameters

layer_id int

get_constant_linear_velocity(int)

Qualifiers: const

Returns the constant linear velocity applied to objects colliding with this tile.

Vector2 get_constant_linear_velocity(int layer_id)

Parameters

layer_id int

get_custom_data(String)

Qualifiers: const

Returns the custom data value for custom data layer named layer_name. To check if a custom data layer exists, use TileData.has_custom_data.

Variant get_custom_data(String layer_name)

Parameters

layer_name String

get_custom_data_by_layer_id(int)

Qualifiers: const

Returns the custom data value for custom data layer with index layer_id.

Variant get_custom_data_by_layer_id(int layer_id)

Parameters

layer_id int

get_navigation_polygon(int, bool, bool, bool)

Qualifiers: const

Returns the navigation polygon of the tile for the TileSet navigation layer with index layer_id.

flip_h, flip_v, and transpose allow transforming the returned polygon.

NavigationPolygon get_navigation_polygon(int layer_id, bool flip_h, bool flip_v, bool transpose)

Parameters

layer_id int
flip_h bool
flip_v bool
transpose bool

get_occluder(int, bool, bool, bool)

Qualifiers: const

Returns the occluder polygon of the tile for the TileSet occlusion layer with index layer_id.

flip_h, flip_v, and transpose allow transforming the returned polygon.

OccluderPolygon2D get_occluder(int layer_id, bool flip_h, bool flip_v, bool transpose)

Parameters

layer_id int
flip_h bool
flip_v bool
transpose bool

get_occluder_polygon(int, int, bool, bool, bool)

Qualifiers: const

Returns the occluder polygon at index polygon_index from the TileSet occlusion layer with index layer_id.

The flip_h, flip_v, and transpose parameters can be true to transform the returned polygon.

OccluderPolygon2D get_occluder_polygon(int layer_id, int polygon_index, bool flip_h, bool flip_v, bool transpose)

Parameters

layer_id int
polygon_index int
flip_h bool
flip_v bool
transpose bool

get_occluder_polygons_count(int)

Qualifiers: const

Returns the number of occluder polygons of the tile in the TileSet occlusion layer with index layer_id.

int get_occluder_polygons_count(int layer_id)

Parameters

layer_id int

get_terrain_peering_bit(int)

Qualifiers: const

Returns the tile's terrain bit for the given peering_bit direction. To check that a direction is valid, use TileData.is_valid_terrain_peering_bit.

int get_terrain_peering_bit(int peering_bit)

Parameters

peering_bit int

has_custom_data(String)

Qualifiers: const

Returns whether there exists a custom data layer named layer_name.

bool has_custom_data(String layer_name)

Parameters

layer_name String

is_collision_polygon_one_way(int, int)

Qualifiers: const

Returns whether one-way collisions are enabled for the polygon at index polygon_index for TileSet physics layer with index layer_id.

bool is_collision_polygon_one_way(int layer_id, int polygon_index)

Parameters

layer_id int
polygon_index int

is_valid_terrain_peering_bit(int)

Qualifiers: const

Returns whether the given peering_bit direction is valid for this tile.

bool is_valid_terrain_peering_bit(int peering_bit)

Parameters

peering_bit int

remove_collision_polygon(int, int)

Removes the polygon at index polygon_index for TileSet physics layer with index layer_id.

void remove_collision_polygon(int layer_id, int polygon_index)

Parameters

layer_id int
polygon_index int

remove_occluder_polygon(int, int)

Removes the polygon at index polygon_index for TileSet occlusion layer with index layer_id.

void remove_occluder_polygon(int layer_id, int polygon_index)

Parameters

layer_id int
polygon_index int

set_collision_polygon_one_way(int, int, bool)

Enables/disables one-way collisions on the polygon at index polygon_index for TileSet physics layer with index layer_id.

void set_collision_polygon_one_way(int layer_id, int polygon_index, bool one_way)

Parameters

layer_id int
polygon_index int
one_way bool

set_collision_polygon_one_way_margin(int, int, float)

Sets the one-way margin (for one-way platforms) of the polygon at index polygon_index for TileSet physics layer with index layer_id.

void set_collision_polygon_one_way_margin(int layer_id, int polygon_index, float one_way_margin)

Parameters

layer_id int
polygon_index int
one_way_margin float

set_collision_polygon_points(int, int, PackedVector2Array)

Sets the points of the polygon at index polygon_index for TileSet physics layer with index layer_id.

void set_collision_polygon_points(int layer_id, int polygon_index, PackedVector2Array polygon)

Parameters

layer_id int
polygon_index int
polygon PackedVector2Array

set_collision_polygons_count(int, int)

Sets the polygons count for TileSet physics layer with index layer_id.

void set_collision_polygons_count(int layer_id, int polygons_count)

Parameters

layer_id int
polygons_count int

set_constant_angular_velocity(int, float)

Sets the constant angular velocity. This does not rotate the tile. This angular velocity is applied to objects colliding with this tile.

void set_constant_angular_velocity(int layer_id, float velocity)

Parameters

layer_id int
velocity float

set_constant_linear_velocity(int, Vector2)

Sets the constant linear velocity. This does not move the tile. This linear velocity is applied to objects colliding with this tile. This is useful to create conveyor belts.

void set_constant_linear_velocity(int layer_id, Vector2 velocity)

Parameters

layer_id int
velocity Vector2

set_custom_data(String, Variant)

Sets the tile's custom data value for the TileSet custom data layer with name layer_name.

void set_custom_data(String layer_name, Variant value)

Parameters

layer_name String
value Variant

set_custom_data_by_layer_id(int, Variant)

Sets the tile's custom data value for the TileSet custom data layer with index layer_id.

void set_custom_data_by_layer_id(int layer_id, Variant value)

Parameters

layer_id int
value Variant

set_navigation_polygon(int, NavigationPolygon)

Sets the navigation polygon for the TileSet navigation layer with index layer_id.

void set_navigation_polygon(int layer_id, NavigationPolygon navigation_polygon)

Parameters

layer_id int
navigation_polygon NavigationPolygon

set_occluder(int, OccluderPolygon2D)

Sets the occluder for the TileSet occlusion layer with index layer_id.

void set_occluder(int layer_id, OccluderPolygon2D occluder_polygon)

Parameters

layer_id int
occluder_polygon OccluderPolygon2D

set_occluder_polygon(int, int, OccluderPolygon2D)

Sets the occluder for polygon with index polygon_index in the TileSet occlusion layer with index layer_id.

void set_occluder_polygon(int layer_id, int polygon_index, OccluderPolygon2D polygon)

Parameters

layer_id int
polygon_index int
polygon OccluderPolygon2D

set_occluder_polygons_count(int, int)

Sets the occluder polygon count in the TileSet occlusion layer with index layer_id.

void set_occluder_polygons_count(int layer_id, int polygons_count)

Parameters

layer_id int
polygons_count int

set_terrain_peering_bit(int, int)

Sets the tile's terrain bit for the given peering_bit direction. To check that a direction is valid, use TileData.is_valid_terrain_peering_bit.

void set_terrain_peering_bit(int peering_bit, int terrain)

Parameters

peering_bit int
terrain int

Events

changed

Emitted when any of the properties are changed.

signal changed