GDQuest / meta

A repository to talk about GDQuest at large, guidelines, etc. all in one place. This is where public discussions that don't belong to a specific repository go.
GNU General Public License v3.0
13 stars 3 forks source link

VisibilityNotifier2D and Enabler2D #7

Closed NathanLovato closed 5 years ago

NathanLovato commented 5 years ago

VisibilityNotifier is great for e.g. an infinite runner game: you can use it to queue_free a node that goes out of the view. I'm using that in Flossy Gnu to spawn a new object when one gets destroyed:

func spawn_pillar() -> void:
    var pillar := pillar_scene.instance()
    pillar.global_position = get_random_position()
    pillar.connect("tree_exited", self, "spawn_pillar")
    pillar.connect("checkpoint_reached", self, "emit_signal", ["pillar_checkpoint_reached"])
    add_child(pillar)
    position.x += spawn_interval

Then, show how to use VisibilityEnabler to disable e.g. an AI's behavior and things like collisions or complex nodes that are outside of the screen. I haven't used it much but it makes sense to use it for realtime AI and large levels. You can use it for optimization, to e.g. only instance parts of a world when the player moves close, and optimize large scenes.

henriiquecampos commented 5 years ago

Video is up, can re-open if needed