Skip to reading
Action Lists & Events

31. Filter completion events carefully

Edition 0.86.4.3

0.86.4.3 edition with revised lessons, updated cross-references and new cinematic/camera-safety supplements. Earlier examples, screenshots and registry figures retain their stated edition context.

Download PDFView PDF page

OnVideoEnd and OnMusicEnd are useful for natural completion. They are not universal notifications for every stop, seek, skip, replacement or loop. Test the exact route you intend to use.

Code example
func on_music_end(event: Dictionary = {}) -> Variant:
    if event.get("musicAssetId", "") != "opening_theme":
        return false
    await ShowMessage({"text": "The room falls quiet.",
                       "duration": 2.2})
    return true

1. Subscribe the script to OnMusicEnd.

2. Use a short, non-looping track for the first test.

3. Let it finish naturally, then repeat the test with Pause/Resume and with Stop.

4. Confirm that the response only runs when the intended completion route occurs.

Visual scripting also has dedicated On Video End and On Music End entry nodes with optional asset filtering. The broad On Event picker does not include those two names in this build. Avoid giving a graph two equivalent completion routes that each grant the same reward.

A returned false value from a listener is not a global "cancel this event" instruction. Keep listeners independent and do not use undocumented return-value conventions as an event priority system.

Page 36 of 189Permalink
Go to page