Skip to main content

Rays and Blocks 03 Released!

·170 words·1 min

Sometimes mirrors and prisms are rendered red to indicate that they’re colliding when the level loads. Once the player moves their mouse over any object to trigger validation the problem goes away.

Weirdly, only some of these objects think they’re colliding. In the previous example, two mirrors are red and one is grey. It turns out they’re colliding with walls from whatever level was loaded previously.

Here’s an overlay of the previous level. I’ve highlighted the spots where the mirrors are colliding with the walls from the previous level.

So that means the previous level hasn’t unloaded by the time the mirrors from the new level are added and are checking for collisions.

All I need to do to fix this is to change the code that unloads the previous level from using the delayed queue_free() to the immediate free(). Done.

func _load_level(level_num: int) -> void:
	if curr_level:
		curr_level.free()
		curr_level = null
    
	...

Alright. Still some things I’d like to do but it’s Friday. I’m cutting a new release: https://nielmclaren.itch.io/raysandblocks03