My game that I'm working on, my character can kill enemies but when the enemies die, they do not lose there collision box, and when I run the game and kill the enemies it comes up with the error in the title.
The entire enemy code is pasted below:
extends KinematicBody2D
const GRAVITY = 10
const SPEED = 30
const FLOOR = Vector2(0, -1)
var velocity = Vector2()
var direction = 1
var is_dead = false
func _ready():
pass
func dead():
is_dead = true
velocity = Vector2(0, 0)
$AnimatedSprite.play("dead")
$CollisionShape2D.disabled = true
$Timer.start()
func _physics_process(delta):
if is_dead == false:
velocity.x = SPEED * direction
if direction == 1:
$AnimatedSprite.flip_h = false
else:
$AnimatedSprite.flip_h = true
$AnimatedSprite.play("walk")
velocity.y += GRAVITY
velocity = move_and_slide(velocity, FLOOR)
if is_on_wall():
direction = direction * -1
$RayCast2D.position.x *= -1
if $RayCast2D.is_colliding() == false:
direction = direction * -1
$RayCast2D.position.x *= -1
func _on_Timer_timeout():
queue_free()
If anyone can solve the problem that would be great because I can't figure it out.