Inheritance #
- AudioServer
- CameraServer
- ClassDB
- DisplayServer
- EditorFileSystemDirectory
- EditorInterface
- EditorPaths
- EditorSelection
- EditorUndoRedoManager
- EditorVCSInterface
- Engine
- EngineDebugger
- FramebufferCacheRD
- GDExtensionManager
- Geometry2D
- Geometry3D
- IP
- Input
- InputMap
- JNISingleton
- JSONRPC
- JavaClassWrapper
- JavaScriptBridge
- MainLoop (1)
- Marshalls
- MovieWriter
- NativeMenu
- NavigationMeshGenerator
- NavigationServer2D
- NavigationServer3D
- Node (21)
- OS
- OpenXRExtensionWrapperExtension
- OpenXRInteractionProfileMetadata
- Performance
- PhysicsDirectBodyState2D (1)
- PhysicsDirectBodyState3D (1)
- PhysicsDirectSpaceState2D (1)
- PhysicsDirectSpaceState3D (1)
- PhysicsServer2D (1)
- PhysicsServer2DManager
- PhysicsServer3D (1)
- PhysicsServer3DManager
- PhysicsServer3DRendering
ServerHandler
- ProjectSettings
- RefCounted (121)
- RenderData (2)
- RenderSceneData (2)
- RenderingDevice
- RenderingServer
- ResourceLoader
- ResourceSaver
- ResourceUID
- ScriptLanguage (1)
- ShaderIncludeDB
- TextServerManager
- ThemeDB
- TileData
- Time
- TranslationServer
- TreeItem
- UndoRedo
- UniformSetCacheRD
- WorkerThreadPool
- XRServer
- XRVRS
- AnimationMixer (2)
- AudioStreamPlayer
- CanvasItem (2)
- CanvasLayer (1)
- EditorFileSystem
- EditorPlugin (1)
- EditorResourcePreview
- HTTPRequest
- InstancePlaceholder
- MissingNode
- MultiplayerSpawner
- MultiplayerSynchronizer
- NavigationAgent2D
- NavigationAgent3D
- Node3D (31)
- ResourcePreloader
- ShaderGlobalsOverride
- StatusIndicator
- Timer
- Viewport (2)
- WorldEnvironment
- AudioListener3D
- AudioStreamPlayer3D
- BoneAttachment3D
- Camera3D (1)
- CollisionObject3D (2)
- CollisionPolygon3D
- CollisionShape3D
- GridMap
- ImporterMeshInstance3D
- Joint3D (5)
- LightmapProbe
- Marker3D
- NavigationLink3D
- NavigationObstacle3D
- NavigationRegion3D
- OpenXRCompositionLayer (3)
- OpenXRHand
- Path3D
- PathFollow3D
- RayCast3D
- RemoteTransform3D
- ShapeCast3D
- Skeleton3D
- SkeletonModifier3D (7)
- SpringArm3D
- SpringBoneCollision3D (3)
- VehicleWheel3D
- VisualInstance3D (13)
- XRFaceModifier3D
- XRNode3D (2)
- XROrigin3D
Table of contents
-
var bake_navigation: bool = false -
var cell_center_x: bool = true -
var cell_center_y: bool = true -
var cell_center_z: bool = true -
var cell_octant_size: int = 8 -
var cell_scale: float = 1.0 -
var cell_size: Vector3 = Vector3(2, 2, 2) -
var collision_layer: int = 1 -
var collision_mask: int = 1 -
var collision_priority: float = 1.0 -
var mesh_library: MeshLibrary -
var physics_material: PhysicsMaterial -
func clear() -> void -
func clear_baked_meshes() -> void -
func get_bake_mesh_instance(idx: int) -> RID -
func get_bake_meshes() -> Array -
const func get_basis_with_orthogonal_index(index: int) -> Basis -
const func get_cell_item(position: Vector3i) -> int -
const func get_cell_item_basis(position: Vector3i) -> Basis -
const func get_cell_item_orientation(position: Vector3i) -> int -
const func get_collision_layer_value(layer_number: int) -> bool -
const func get_collision_mask_value(layer_number: int) -> bool -
const func get_meshes() -> Array -
const func get_navigation_map() -> RID -
const func get_orthogonal_index_from_basis(basis: Basis) -> int -
const func get_used_cells() -> Vector3i[] -
const func get_used_cells_by_item(item: int) -> Vector3i[] -
const func local_to_map(local_position: Vector3) -> Vector3i -
func make_baked_meshes(lightmap_uv_texel_size: float = 0.1) -> void -
const func map_to_local(map_position: Vector3i) -> Vector3 -
func resource_changed(resource: Resource) -> void -
func set_cell_item(orientation: int = 0) -> void -
func set_collision_layer_value(value: bool) -> void -
func set_collision_mask_value(value: bool) -> void -
func set_navigation_map(navigation_map: RID) -> void -
const INVALID_CELL_ITEM = -1 -
signal cell_size_changed(cell_size: Vector3) -
signal changed()
GridMap #
is_instantiable, Node3D, Node, core, not_builtin_classes
Node for 3D tile-based maps.
GridMap lets you place meshes on a grid interactively. It works both from the editor and from scripts, which can help you create in-game level editors.
GridMaps use a MeshLibrary which contains a list of tiles. Each tile is a mesh with materials plus optional collision and navigation shapes.
A GridMap contains a collection of cells. Each grid cell refers to a tile in the MeshLibrary. All cells in the map have the same dimensions.
Internally, a GridMap is split into a sparse collection of octants for efficient rendering and physics processing. Every octant has the same dimensions and can contain several cells.
Note: GridMap doesn't extend VisualInstance3D and therefore can't be hidden or cull masked based on VisualInstance3D.layers. If you make a light not affect the first layer, the whole GridMap won't be lit by the light in question.
Members #
var bake_navigation: bool = false#
If true, this GridMap creates a navigation region for each cell that uses a mesh_library item with a navigation mesh. The created navigation region will use the navigation layers bitmask assigned to the MeshLibrary's item.
var cell_center_x: bool = true#
If true, grid items are centered on the X axis.
var cell_center_y: bool = true#
If true, grid items are centered on the Y axis.
var cell_center_z: bool = true#
If true, grid items are centered on the Z axis.
var cell_octant_size: int = 8#
The size of each octant measured in number of cells. This applies to all three axis.
var cell_scale: float = 1.0#
The scale of the cell items.
This does not affect the size of the grid cells themselves, only the items in them. This can be used to make cell items overlap their neighbors.
var cell_size: Vector3 = Vector3(2, 2, 2)#
The dimensions of the grid's cells.
This does not affect the size of the meshes. See cell_scale.
var collision_layer: int = 1#
The physics layers this GridMap is in.
GridMaps act as static bodies, meaning they aren't affected by gravity or other forces. They only affect other physics bodies that collide with them.
var collision_mask: int = 1#
The physics layers this GridMap detects collisions in. See Collision layers and masks in the documentation for more information.
var collision_priority: float = 1.0#
The priority used to solve colliding when occurring penetration. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
var mesh_library: MeshLibrary#
The assigned MeshLibrary.
var physics_material: PhysicsMaterial#
Overrides the default friction and bounce physics properties for the whole GridMap.
Methods #
func clear() -> void#
Clear all cells.
func clear_baked_meshes() -> void#
Clears all baked meshes. See make_baked_meshes.
func get_bake_meshes() -> Array#
Returns an array of ArrayMeshes and Transform3D references of all bake meshes that exist within the current GridMap.
const func get_basis_with_orthogonal_index(index: int) -> Basis#
Returns one of 24 possible rotations that lie along the vectors (x,y,z) with each component being either -1, 0, or 1. For further details, refer to the Godot source code.
const func get_cell_item(position: Vector3i) -> int#
The MeshLibrary item index located at the given grid coordinates. If the cell is empty, INVALID_CELL_ITEM will be returned.
const func get_cell_item_basis(position: Vector3i) -> Basis#
Returns the basis that gives the specified cell its orientation.
const func get_cell_item_orientation(position: Vector3i) -> int#
The orientation of the cell at the given grid coordinates. -1 is returned if the cell is empty.
const func get_collision_layer_value(layer_number: int) -> bool#
Returns whether or not the specified layer of the collision_layer is enabled, given a layer_number between 1 and 32.
const func get_collision_mask_value(layer_number: int) -> bool#
Returns whether or not the specified layer of the collision_mask is enabled, given a layer_number between 1 and 32.
const func get_meshes() -> Array#
Returns an array of Transform3D and Mesh references corresponding to the non-empty cells in the grid. The transforms are specified in local space.
const func get_navigation_map() -> RID#
Returns the RID of the navigation map this GridMap node uses for its cell baked navigation meshes.
This function returns always the map set on the GridMap node and not the map on the NavigationServer. If the map is changed directly with the NavigationServer API the GridMap node will not be aware of the map change.
const func get_orthogonal_index_from_basis(basis: Basis) -> int#
This function considers a discretization of rotations into 24 points on unit sphere, lying along the vectors (x,y,z) with each component being either -1, 0, or 1, and returns the index (in the range from 0 to 23) of the point best representing the orientation of the object. For further details, refer to the Godot source code.
const func get_used_cells() -> Vector3i[]#
Returns an array of Vector3 with the non-empty cell coordinates in the grid map.
const func get_used_cells_by_item(item: int) -> Vector3i[]#
Returns an array of all cells with the given item index specified in item.
const func local_to_map(local_position: Vector3) -> Vector3i#
Returns the map coordinates of the cell containing the given local_position. If local_position is in global coordinates, consider using Node3D.to_local before passing it to this method. See also map_to_local.
func make_baked_meshes(lightmap_uv_texel_size: float = 0.1) -> void#
Bakes lightmap data for all meshes in the assigned MeshLibrary.
const func map_to_local(map_position: Vector3i) -> Vector3#
Returns the position of a grid cell in the GridMap's local coordinate space. To convert the returned value into global coordinates, use Node3D.to_global. See also local_to_map.
func resource_changed(resource: Resource) -> void#
This method does nothing.
func set_cell_item(orientation: int = 0) -> void#
Sets the mesh index for the cell referenced by its grid coordinates.
A negative item index such as INVALID_CELL_ITEM will clear the cell.
Optionally, the item's orientation can be passed. For valid orientation values, see get_orthogonal_index_from_basis.
func set_collision_layer_value(value: bool) -> void#
Based on value, enables or disables the specified layer in the collision_layer, given a layer_number between 1 and 32.
func set_collision_mask_value(value: bool) -> void#
Based on value, enables or disables the specified layer in the collision_mask, given a layer_number between 1 and 32.
func set_navigation_map(navigation_map: RID) -> void#
Sets the RID of the navigation map this GridMap node should use for its cell baked navigation meshes.
Annotations #
Constants #
const INVALID_CELL_ITEM = -1#
Invalid cell item that can be used in set_cell_item to clear cells (or represent an empty cell in get_cell_item).
Constructors #
Enums #
Notifications#
enum {
INVALID_CELL_ITEM = -1,
}Operators #
Signals #
signal cell_size_changed(cell_size: Vector3)#
Emitted when cell_size changes.
signal changed()#
Emitted when the MeshLibrary of this GridMap changes.