Collision between Area3D and StaticBody3D not working as expected

Godot Version

4.4.1

Question

I’m pretty new to godot and have started to create a little twin stick shooter prototype. Everything has been smooth until I got to bullets vs world collision detection. I am on godot 4.4.1.

I am using an Area3D with monitoring/monitorable enabled and my stage bounds are just CSGBox that if I am not mistaken generate StaticBody3D collisions.

My problem is that sometimes when firing, some collisions are detected and others don’t depending of the distance of the fire point against the CSGBox. My CSGBox is pretty wide and the bullets stay inside the CSGBox while moving several frames.

Key points:

1 - Bullet is using Area3D
2 - Walls are using a CSGBox
3 - I detect collisions manually using get_overlapping_bodies on the bullet. I have tried to await a frame as documentation states but I get same result. All movement and collision detection is made inside _physics_process. Code below of my weapon class that is the one that generates the bullets and handle collsiion:

func _physics_process(delta: float) -> void:
	
	var i=0;
	while i<used_bullets.size():
		var bullet = used_bullets[i];
		var bodies = bullet.get_overlapping_bodies();
		if bodies.size() > 0:
			get_tree().root.remove_child(bullet)
			pool_mgr.getPool(pool_id).recycle(bullet)
			used_bullets[i] = used_bullets[used_bullets.size()-1]
			used_bullets.pop_back()
			print("Collided!")
		else:
			i+=1;
		bullet.position +=-bullet.transform.basis.z*delta*40

Here is a screenshot of my test level:

Why can this be happening? I can upload a little video if needed to clarify anything.
Thanks in advance!

My guess is it is the speed of your bullets. They are probably moving so fast that they are skipping over the collision area. When you update the velocity of something, it doesn’t move through all the intervening positions on a line - it teleports. So it’s teleporting right over your box.

BTW, CSGs are only good for prototyping in Godot, as their performance, per the docs, is awful. I’d recommend you use a normal MeshInstance3D for your walls.

Well, I moved from CSGBoxes to StaticBody3D and everything worked as expected. That’s the price that a newbie to godot needs to pay. Almost 4 hours trying things to figure out CSGBoxes are a bit meh related to collision detection.

Thanks anyway for the suggestions. You were on the right track :).

1 Like

I’ll take the win. Glad to help. :slight_smile: