multimesh2d
Godot's MultiMeshInstance2D: the multimesh asset in source, its mesh drawn flat once per instance in one call, each instance tinted over color. The node…
On this page
2d · render · 5 properties · 2D
Godot's MultiMeshInstance2D: the multimesh asset in source, its mesh drawn flat once per instance in one call, each instance tinted over color. The node keeps its own copy of the instances, so a script's edits stay on it; children draw once.
In a scene, multimesh2d is the node key that applies it. A script reaches each property below as a field on node.multimesh2d: reading one asks the running component, and assigning one leaves the rest alone. The whole table is node.multimesh2d.get() and node.multimesh2d.set(table).
Properties
| property | type | default | description |
|---|---|---|---|
color |
color | [1,1,1,1] |
Tint under every instance's own colour, as channel floats or #rrggbb / #rrggbbaa |
material |
asset · material |
— | The material this draws with; empty takes an inherited material component, else the built-in one |
pixels_per_unit |
float | 100 |
Texture pixels per world unit, for a mesh that carries no UVs of its own At least 0.01. |
source |
asset · multimesh |
— | The multimesh asset: the mesh and the instances it is drawn at |
texture |
asset · texture |
— | Image file, project-relative, or a texture asset; empty draws the colour alone |
Asset types this component references: material, multimesh, texture.
Script functions
Methods of node.multimesh2d, the handle a node carrying this component exposes. Every handle also has get(), set(table), patch(table), has() and remove().
From multimesh2d:
| method | what it does |
|---|---|
buffer() -> [float] |
Every instance as one flat list of floats in Godot's MultiMesh.buffer layout: 12 of transform in 3D or 8 in 2D, then 4 of colour and 4 of custom data. |
instance_color(int) -> Color |
The colour one instance draws in. |
instance_count() -> int |
How many instances the node holds. |
instance_custom_data(int) -> Color |
One instance's four floats of custom data, as a colour. |
instance_region(int) -> render::InstanceRegion? |
One instance's texture rectangle in pixels, or nil when it draws the whole texture. |
instance_transform(int) -> Transform2d |
One instance's transform. |
instances() -> [render::MultimeshInstance] |
Every instance as the multimesh asset spells it, so assets.save writes a scripted layout into a file. |
populate(render::PopulateOptions) -> [render::MultimeshInstance] |
Godot's Populate Surface, and a row, a ring or a grid: the instances a layout would write, worked out from seed, returned in the multimesh asset's shape rather than set. kind is render.POPULATE_SURFACE with a surface node, POPULATE_ROW (count, step), POPULATE_RING (count, radius) or POPULATE_GRID (counts, step); rotation, tilt and random_scale vary each instance, as fractions, around scale. |
set_buffer([float]) |
Replace every instance from one flat list in the layout buffer answers in, for a Godot port that sets buffer. Building the list in a script costs more than one set_instance_transform per instance. |
set_instance_color(int, Color) |
The colour one instance draws in. |
set_instance_count(int) |
How many instances the node holds. Those below the count keep where they were; new ones are plain, at the node. |
set_instance_custom_data(int, Color) |
Four floats a material's shader reads for one instance, as a colour. |
set_instance_region(int, Vec2, Vec2) |
The rectangle of the texture one instance draws, as an origin and a size in texture pixels; a zero size draws all of it. Not drawn yet: multimesh2d draws through Balaur's own pipeline, which binds no rectangle per instance. |
set_instance_transform(int, Transform2d) |
Place one instance. A shear is kept, as the instance's basis. |
set_instances([render::MultimeshInstance]) |
Replace every instance with a list in the multimesh asset's shape. |
set_visible_instance_count(int) |
How many instances draw, from the first; -1 draws them all. |
visible_instance_count() -> int |
How many instances draw; -1 is all of them. |