From 7a7af4cf4e32847c990086f7522cb246a869b8c9 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Mon, 25 Oct 2021 23:16:29 +0200 Subject: [PATCH] Don't check bullet collision with other bullets in the Bullet shower demo This improves performance by reducing the number of collision checks that need to be done. --- 2d/bullet_shower/bullets.gd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/2d/bullet_shower/bullets.gd b/2d/bullet_shower/bullets.gd index 7144925d..ecb2d11e 100644 --- a/2d/bullet_shower/bullets.gd +++ b/2d/bullet_shower/bullets.gd @@ -38,6 +38,10 @@ func _ready(): Physics2DServer.body_set_space(bullet.body, get_world_2d().get_space()) Physics2DServer.body_add_shape(bullet.body, shape) + # Don't make bullets check collision with other bullets to improve performance. + # Their collision mask is still configured to the default value, which allows + # bullets to detect collisions with the player. + Physics2DServer.body_set_collision_layer(bullet.body, 0) # Place bullets randomly on the viewport and move bullets outside the # play area so that they fade in nicely.