Skip to content

CollisionsCheckRule

Rule that validates placement based on collision detection.

This rule checks for physics collisions at indicator positions and validates based on the [member pass_on_collision] setting: - false (default): Placement FAILS if collision detected (“must have clear space”) - true: Placement FAILS if NO collision detected (“must overlap with existing objects”)

pass_on_collision = false

Controls collision validation behavior: - false: Rule PASSES when no collision (placement requires clear space) - true: Rule PASSES when collision detected (placement requires overlap)

Common use cases: - false: Building placement (needs empty space) - true: Attachment mechanics (must connect to existing structures)

messages: CollisionRuleSettings

Modular message configuration resource

func _init( )
func setup( p_gts: GridTargetingState ) -> Array[String]

Setup the rule with the provided GridTargetingState. Returns an array of issues found during setup. p_gts: GridTargetingState - The targeting state to use for placement [returns] Array[String] - Array of issues found during setup

func validate_placement( ) -> RuleResult

Validates placement by checking collisions on all provided indicators. Returns a RuleResult with success/failure and messages.

func get_failing_indicators( p_indicators: Array[RuleCheckIndicator] ) -> Array[RuleCheckIndicator]

Runs the rule against an array of indicators. Returns the number of failing indicators.

p_indicators: Array[RuleCheckIndicator] - Array of indicators to test collision against :::note[Note] This method is public and should be used directly by callers. The previous private wrapper _get_failing_indicators was removed to simplify the API. :::

func _indicator_apply_target_exceptions( indicator: ShapeCast2D ) -> void

Add all CollisionObject2D under the preview target as exceptions on the shape cast. Also adds any nodes from GridTargetingState.collision_exclusions (e.g., original object during manipulation move).

func _collect_bodies_recursive( node: Node, out: Array[CollisionObject2D] ) -> void
func get_editor_issues( ) -> Array[String]

Returns an array of issues found during editor validation

func get_runtime_issues( ) -> Array[String]

Returns an array of issues found during runtime validation

addons/grid_building/placement/placement_rules/template_rules/collisions_check_rule.gd


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