Skip to content

Commit 7a7af4c

Browse files
committed
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.
1 parent 1916f87 commit 7a7af4c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

2d/bullet_shower/bullets.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func _ready():
3838

3939
Physics2DServer.body_set_space(bullet.body, get_world_2d().get_space())
4040
Physics2DServer.body_add_shape(bullet.body, shape)
41+
# Don't make bullets check collision with other bullets to improve performance.
42+
# Their collision mask is still configured to the default value, which allows
43+
# bullets to detect collisions with the player.
44+
Physics2DServer.body_set_collision_layer(bullet.body, 0)
4145

4246
# Place bullets randomly on the viewport and move bullets outside the
4347
# play area so that they fade in nicely.

0 commit comments

Comments
 (0)