by Jon (Updated on 2015-10-18)
Custom Events are events that happen only when you tell them to happen. Why would you want to do this?
Reuse Logic. If you're finding that you're copying and pasting the same code, you could stick it into a Custom Event and trigger that Custom Event instead.
Aside: In programming terms, Custom Events are equivalent to the concept of "messaging" or "indirect invocation" - they aren't quite the same as function calls since you aren't always specifying a receiver. There can be as few as 0 receivers or infinitely many.
Inside the Behavior Designer, go to Add Event > Advanced > Custom Event.
Type something into the blank. This is the text that will cause this Custom Event to trigger.
That's it! Now fill out what you want to happen inside the event.
Custom Events are triggered by any one of the blocks under Behavior > Triggers. The act of telling a Custom Event to happen is called triggering.
To trigger an event, put in the text you stuck into the blank when defining the event.
As you have may noticed, triggering Custom Events can be done directly (one behavior) or indirectly (all behaviors). This to say:
You can specify exactly which behavior you're targeting.
Note: If a behavior doesn't have a Custom Event and you try to trigger it, nothing happens. It's ignored.
Sometimes, you may want to make a Custom Event configurable. Which is say that you would want to stick a Text Attribute into the blank.
You can do this, and as you'd expect, the text for Custom Event becomes configurable.
Warning: Do not change the value of the Text Attribute at runtime during the game. The Custom Event may break if you do this.
Custom Events and Custom Blocks overlap somewhat in use case. However, they differ in several respects, as summarized below.