Intended or bug?: AStarGrid2D.update() no longer clears solid cells in 4.3

Godot Version

4.3

Question

Calling update() on an AStarGrid2D seems to no longer clear solidity/weight of cells, despite the documentation stating “all point data (solidity and weight scale) will be cleared.” This worked in v4.2.2, but no longer works in 4.3. Is this intended? I couldn’t find any release notes stating that this has been changed.

Am I missing something or should I report a bug? Reproduction method below.

  1. Create new project with a new scene
  2. Add the script below to the scene’s root Node
  3. Run the scene and note the results of the prints
extends Node

func _ready():
	print("HELLO")
	
	# Create the AStarGrid2D
	var astar = AStarGrid2D.new()
	astar.region = Rect2i(0,0,3,3)
	astar.update()
	
	# Set one of the grid's cells as solid and change its weight
	astar.set_point_solid(Vector2i(1,1), true)
	astar.set_point_weight_scale(Vector2i(1,1), 10.0)
	
	# Update the AStarGrid2D: according to the docs, "all point data (solidity and weight scale) will be cleared", resetting the cell we changed... right?
	astar.update()
	
	for n in astar.region.size.x:
		for m in astar.region.size.y:
			# For each cell; print whether it's solid or not. All cells SHOULD be non-solid because of the update()
			print(str(Vector2i(n,m)) +": " +str(astar.is_point_solid(Vector2i(n,m))) + " | " + str(astar.get_point_weight_scale(Vector2i(n,m))))
			
			# Godot 4.2.2: Prints everything as 'false' as with a weight of "1"
			# Godot 4.3: The cell we changed earlier is still printed as solid being 'true', with a weight of "10", despite having called update()
1 Like

The function still cleaning the the solid cells, but what changed now is if you call update when that wasn’t needed (when the astar is not dirty / is_dirty return false) the function will exit early and do nothing, so in your case you’re calling update when the astar is not dirty, so the function just do nothing.

See more: Add a check to prevent user to call `AStarGrid2D::update` when its not needed by Chaosus · Pull Request #93993 · godotengine/godot · GitHub

1 Like

Ah I see, I suppose that makes sense, though perhaps it may warrant a change to the documentation. Good to know, thanks for the insight!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.