What is "area_set_shape_disabled"?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By flamerunner

I’m coding with the help of a tutorial, and my debugger is going wild and crashing my game. It says that area_set_shape is disabled it can’t change it while flushing queries. It also says to use call_deffered() or set_deffered but I have no clue as a beginner, what that means.

The code:


my code

extends KinematicBody2D

const ACCELERATION =100
const MAX_SPEED=80
const FRICTION = 100000000000000000
enum{
	MOVE,
	ROLL,
	ATTACK
}


var state= MOVE
var velocity=Vector2.ZERO


onready var animationPlayer= $AnimationPlayer
onready var animationTree = $AnimationTree
onready var animationState=animationTree.get("parameters/playback") 


func _process(delta):
	match state:
		MOVE:
			move_state(delta)
		ROLL:
			pass
		ATTACK:
			attack_state(delta)
	
	

func move_state(delta):
	var input_vector = Vector2.ZERO
	input_vector.x= Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
	input_vector.y= Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
	input_vector= input_vector.normalized()
	
	
	if input_vector != Vector2.ZERO:
		animationTree.set("parameters/Idle/blend_position", input_vector)
		animationTree.set("parameters/Run/blend_position", input_vector)
		animationTree.set("parameters/Attack/blend_position", input_vector)
		animationState.travel("Run")
		velocity= velocity.move_toward(input_vector*MAX_SPEED, ACCELERATION*delta)
	else:
		animationState.travel("Idle")
		velocity = velocity.move_toward(Vector2.ZERO, FRICTION*delta)
		
	velocity=move_and_slide(velocity)
	
	if Input.is_action_just_pressed("attack"):
		state = ATTACK
	
func attack_state(delta):
	animationState.travel("Attack")
	velocity = velocity.move_toward(Vector2.ZERO, FRICTION/2 * delta)
	velocity = move_and_slide(velocity)

func attack_animation_finished():
	state= MOVE

other code in game

extends Node2D

onready var animatedSprite = $AnimatedSprite


func _ready():
	animatedSprite.frame=0
	animatedSprite.play("default")
	


func _on_AnimatedSprite_animation_finished():
	queue_free()


extends Node2D

func create_grass_effect():
	var GrassEffect = load("res://Grass.tscn")
	var grassEffect= GrassEffect.instance()
	var world= get_tree().current_scene
	world.add_child(grassEffect)
	grassEffect.global_position = global_position
func _on_Area2D_area_entered(area):
	create_grass_effect()
	queue_free()

UPDATE

Wrong word. Easy fix.

flamerunner | 2023-01-16 23:58

Edited to fix code formatting. Please use the {} button in future posts to format code. And, look at the Preview panel before posting. If it’s not formatted there, it won’t be formatted when you post.

jgodfrey | 2023-01-17 00:02

:bust_in_silhouette: Reply From: Inces

When physical object is queued free, its shapes are first disabled. Physical engine can’t do this every frame, and it advises You to use call_deferred to slow down this process
So use call_deferred("queue_free") instead of just queue_free()evrywhere in tjhis code