Hi, I am having a werid crash problem when deleting a Node3D with a child Area3D node.
Basically I create like 30 objects with Area3D + CollisionShape3D(with a Box collision shape) per mouse click,
then I give them a timed-life of a 8 seconds, after 8 seconds they queue-free themselves.
But it seems after I spam like a few hundreds of Node3D, the game just crashes to desktop with an error in console:
"ERROR:ERROR:ERROR: FATAL: Index p_index = 0 is out of bounds (shapes.size() = 0).
FATAL: Index p_index = 0 is out of bounds (shapes.size() = 0).
FATAL: Index p_index = 0 is out of bounds (shapes.size() = 0).
at: at: get_shape_transform (servers/physics_3d/godot_collision_object_3d.h:128)
get_shape_transform (servers/physics_3d/godot_collision_object_3d.h:128)"
I did read about the docs about node deletion, it seems I don't need to manually free 'children' of a parent Node , since it frees all siblings automatically with queue-free function.
Here is the object I spammed in game to stress-test the problem:
And this is the code I used to auto-free upon object timeout:
extends Node3D
var speed : Vector3 = Vector3.ZERO
var life_start : float = -1.0
var life_span : float = 8.0
var dying : bool = false
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if self.is_queued_for_deletion():
return
var now_time : float = Time.get_unix_time_from_system()
if life_start < 0:
life_start = now_time
var life_elapsed = now_time - life_start
if life_elapsed >= life_span:
dying = true
hide()
queue_free()
var desire_x = delta * speed.x
var desire_y = delta * speed.y
var desire_z = delta * speed.z
self.transform.origin.x += desire_x
self.transform.origin.y += desire_y
self.transform.origin.z += desire_z
func set_velocity(vel):
speed = vel
pass
Thanks.
EDIT::
Update:
Just tested spamming objects without 'queue-freeing' them, the number of objects actively reached 4k, and there is still no sign of crash after a few minutes -.-