Skip to content

Class

GridPositioner2D

Generated GDScript class reference for GridPlacement.GridPositioner2D.

Status
Current
Version
v6.0
Source updated
Active v6.0 guide line from Grid Placement repo
Generated on
2026-09-01

Controls the on-grid cursor used by building/interaction systems. Responsibilities:

  • Recenter according to GridTargetingSettings policy when input/mode is enabled
  • Follow mouse/keyboard input to update on-grid position
  • STRICTLY for tile center targeting
  • does NOT handle rotation or manipulation Targeting separation: Target acquisition/collision detection is handled by dedicated components (e.g., TargetingShapeCast2D). GridPositioner2D no longer depends on or manages any shapecast component. Manipulation separation: Object rotation, flipping, and manipulation are handled by ManipulationParent. GridPositioner2D focuses solely on positioning the targeting cursor at tile centers. Dependency Injection: resolve_placement_dependencies(container) is the standard method called by PlacementInjectorSystem to inject dependencies. This is the primary integration pattern for runtime use. set_dependencies(...) is an internal helper for testing and advanced use cases.

Source: addons/grid_placement/systems/grid_targeting/grid_positioner/grid_positioner_2d.gd

Syntax

class GridPositioner2D extends Node2D

Members

NameKindSummary
sessionPropertyHost pattern (canonical): the [PlacementSession] this positioner pulls its dependencies from. When set, [method _ready] self-configures and registers with the nearest [GridPlacementHost] for input routing. Leave null to use the deprecated injector pattern.
LOG_PREFIXField
set_targeting_stateMethod
cursor_sourcePropertyInjected cursor-source callable. Returns a [Vector2] screen position. If the callable returns [code]null[/code], or if [member cursor_source] is not set, falls back to the real viewport mouse position. Tests inject a callable that returns a fixed Vector2 for deterministic positioning. Usage in tests: positioner.cursor_source = func(): return Vector2(100, 100)
input_processing_enabledPropertyPublic flag & API for enabling/disabling input processing (used by tests)
set_input_processing_enabledMethod
is_input_processing_enabledMethod
is_input_readyMethod
are_dependencies_readyMethod
resolve_placement_dependenciesMethod
move_to_viewport_center_tileMethod
move_to_cursor_center_tileMethod
remove_self_as_positionerMethod
update_visibilityMethod
should_be_visibleMethod
set_dependenciesMethod
get_runtime_issuesMethod
validate_dependenciesMethod
get_visual_nodeMethod
is_visual_visibleMethod
is_positioner_activeMethod
are_dependencies_resolvedMethod
to_diagnostic_stringMethod