Could we assume that if `next_level` is `null` that we are on the final level?

I challenged myself to do the logic ahead of the lecture on showing the win screen, and I came up with this:

func _on_exit_body_entered(body):
	if body is Player:
		exit.animate() = false
		win = true

		await get_tree().create_timer(1.5).timeout
		if next_level != null:

It seems like it would be relatively safe to assume that if next_level == null that we are on the final level and don’t need to explicitly set a bool to specify the final level. I know future me would definitely forget to set that flag on the final level if the game got much more complicated, and this approach seems to handle it automatically.


Nice one, yea, makes sense fab work :+1:


This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms