Skip to content

TargetingShapeCast2D

Encapsulates ShapeCast2D-based targeting logic as a reusable component

debug_log_collisions: bool = false

GB dependencies (typed)

Local debug flag: can be toggled per-instance in editor or by code

func resolve_gb_dependencies( p_container: GBCompositionContainer ) -> void

Resolve Grid Building dependencies (logger, targeting state)

func _physics_process( _delta: float ) -> void

Physics process: continuously update targeting state based on ShapeCast2D collisions

func update_target( ) -> void

Update the GridTargetingState.target based on current collisions Skips automatic updates when manipulation is active (target set manually)

func _log_collisions( ) -> void

Log current collisions for diagnostics

func _format_collision_layers( mask: int ) -> String

Format collision mask as layer names or numbers

func _promote_to_targetable_root( raw: Object ) -> Node2D

Promote a raw collider (which may be a child physics body) to its root Area2D if that root represents the intended gameplay target. This handles scenes like the Smithy where the visual/physics StaticBody2D is a child of an Area2D which carries the targetable layer. raw: The collider returned by ShapeCast2D. Returns: A Node2D to use as targeting root (prefer Area2D on targetable layer) or the original if no promotion needed.

addons/grid_building/systems/grid_targeting/grid_positioner/targeting_shape_cast_2d.gd


This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.