Same crash, different error.

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

A while ago I posted on here because my game was crashing for seemingly no reason and only occasionally gave me a partial error message that didn’t exactly clear things up. Now I have the same issue, but a different error message that leaves me even more confused.

E 0:00:03:0256 get_shape_transform: FATAL: Index p_index = 0 is out of bounds (shapes.size() = 0).
<C++ Source> servers/physics_2d/godot_collision_object_2d.h:121 @ get_shape_transform()

When this error occurs, I either get none of them showing up in the debugger but it must be the cause of the crash because it seems to be the only consistent thing, or I get multiple of them. The lowest I’ve seen was 2, and the most was 21. I can’t tell what’s going on, but it must be happening somewhere around when I try to queue the player’s bullets for deletion, and if it’s happening there it could be happening on any of my other code as well.

I’ve had this error for weeks and brought it to multiple sources to no avail. Suspect code sections are as follows:

Player Bullet:

extends Area2D

var speed = 10

func _ready():

func init(player):
	position = player.position

func _physics_process(delta):
	if not self.is_queued_for_deletion():
		position.y -= speed

func _on_area_entered(area):
	if area.is_in_group("Enemies"):

Player Firing Code:

#Weapons firing code
if Input.is_action_pressed("Fire") && shotCooldown<=0:
	shot = bullet.instantiate()
	shotCooldown = 1.0

if shotCooldown > 0.0:

Test Entity Code:

extends Area2D

var hp = 1

var calzone
func init(x,y):
	position = Vector2(x,y)

func _ready():
	calzone = get_node("/root/GameWorld/Camera2D/EntityManager/CullZone")

func _physics_process(delta):
	if hp<=0:

func hit(damage):

func cull(_area):
	if calzone.overlaps_area(self) && !is_queued_for_deletion():

These are the only things that have code that interact with the player bullet. The error happens seemingly randomly, either happening in the first 40 frames of running the game or never popping at all. I’m utterly dumbfounded on this one.

:bust_in_silhouette: Reply From: DigitalUnity

Same as a different question I asked. Broken for unknown reasons, not the bullet code, I’ve been tearing my hair out for the wrong reasons.