IntroductionThe sends signal and has received signal capacities follow the logic of the observer design pattern commonly used in software development. The observer design pattern is a behavioral pattern where a first object (subject) emits a signal, message, or notification to other dependent objects (observers). These observers subsequently perform an action when they receive the notification. The subject and its condition maintain this list of dependent observers. The observer design pattern helps to reduce the dependencies between the subject and the observers, with the following benefits:
Sending and receiving signals greatly simplifies the construction of your scripts by:
Note:
The
StuSignalEvent event lets you interact with the signals emitted
in Natural Language to use them in JavaScript and the
Behavior Editor. The event also lets you send signals from
JavaScript that Natural Language can receive.For more information, see the JavaScript API Guide of Creative Experience. ModalitiesThe sends signal and has received signal capacities both take a string parameter (no custom Event type) that defines the signal (as a message) to send or receive. The signal is case-sensitive. For example, "myMessage" does not equate "mymessage".
The capacities require the following actor types:
You cannot send or receive signals without an actor. There is no general broadcasting system. In addition, you cannot send messages to inactive actors. Ensure that your actors are active, especially when transitioning between scenes. Practical ApplicationConsider the following paragraph in a scenario:
Changing the subject (myActor1) requires changing all the other sentences for the whole paragraph to stay valid. Using the observer design pattern and a signal system, you can make this paragraph more adaptable and convenient to modifications:
Using this construction, changing the subject (myActor1) requires changing only the first sentence for the whole paragraph to stay valid. Compatibility of the Capacities with Logical OperatorsYou can use the sends signal driver with all the sensor operators. When using the While operator with sends signal, the Scenario Editor displays a warning indicating that you can encounter performance issues. You can use the has received signal sensor with the If and Each Time sensor operators but not with While because it is an event. Sending a signal corresponds to sending an event and occurs once per frame. Therefore, using Each Time sends a signal every time the condition meets its requirements. In addition, you cannot negate the has received signal sensor because negating an event is not relevant. The following table summarizes the compatibility of each capacity with the logical operators:
| |||||||||||||||||||||||||||