-
Notifications
You must be signed in to change notification settings - Fork 0
Create SocialEvents Using ScriptableObjects
Shi Johnson-Bey edited this page Feb 21, 2024
·
2 revisions
Users can create Social Event types directly in the Unity Editor using ScriptableObjects. Using ScriptableObjects has the benefit of taking advantage of Unity's asset management pipeline.
- Right-click in the Project window and select
Create > TDRS > Social Event
. - Name the new asset whatever you wish.
- Set the desired social event fields (described below).
- Add the asset to the
Social Events
list on theSocialEngineController
within your scene. - Try dispatching the event with some characters.
- The sample code in the repo implements a
MockSocialEventCreator
(located inAssets/TDRS_Demo/Scripts/
). This class allows you to specify an event type and a list of characters to bind to the event roles (in order).
- The sample code in the repo implements a
-
Event Name
: (required) The name of the event (used when specifying which event to dispatch) -
Roles
: (optional) The names of roles of characters who are involved in the social event -
Description
: (optional) A string description describing the social event.- This string uses a
[role_name]
template syntax that will substitute role names with the UIDs of the agents bound to those roles. For example, a description of[group_a] ended their feud with [group_b]
, will expand tomontagues ended their feud with capulets
assuming that agents with UIDsmontagues
andcapulets
were bound to rolesgroup_a
andgroup_b
, respectively.
- This string uses a
-
Responses
: This is where you specify how agents should react to this event. Each entry corresponds to a different response. Agents can respond to the same event multiple times, assuming they pass the preconditions for multiple response entries.-
Preconditions
: These are RePraxis query statements that run against TDRS's database. Any variables bound with the query can be used within the effect functions. -
Effects
: Effect functions to trigger when dispatching this event. You can read more about effect functions on the Social Events Page. -
Description
: A response-specific description. Both even role names and precondition variable names are eligible for substitution using the square bracket syntax.
-
Below is a screenshot of a Social Event Scriptable Object that defines a betrayal event.