NotificationCenterSubscribeEntityPicking - Create A Trigger Based On When A User Clicks An Object
This guide provides instructions for setting up the NotificationCenterSubscribeEntityPicking trigger. In the sample app, the user clicks on the whale and the whale switches to the jump animation state.
The whale starts in the idle animation state. | When the user clicks on the whale, the whale switches to the jump animation state. |
1. In this example, a trigger area is created on a 3D model and when the user clicks on the trigger area, an action causes the 3D model to play an animation. Any object can be used as a trigger, as long as the object has a Collision component. Because this specific example creates a trigger area over a 3D model, a simple box shape collider is used. The entity does not have a RigidBody component. To create the animation state graph, right-click in the Assets window and select New Asset > Anim State Graph.
A. Give the animation state graph a name.
B. Click the "Open Graph Editor" button to open the graph.
2. To add an additional animation state to the graph, right-click on the graph and select Add New State.
A. Rename the animation states. In this example, the Initial State animation has been changed to Idle. Confirm that the checkbox for loop is enabled.
B. In this example, the new animation state has been changed to Jump. Confirm that the checkbox for loop is disabled.
C. Close the animation state graph by clicking the X.
3. To configure the model that will be animated, select the 3D model in the Hierarchy.
A. Click the "Add Component" button. Select Physics > Collision to add a Collision component.
B. Click the "Add Component" button. Select Animation > Anim to add the Anim component. Add the animation state graph that was created to the State Graph field.
C. Add an idle animation to the Idle animation state.
D. Add a jump animation to the Jump animation state.
E. Resize the collider to the desired size. In this example, the Half Extents field has been set to (.5, .5, 2) for X, Y, Z.
4. To add the NotificationCenterSubscribeEntityPicking trigger
A. Click the Select plugins text field and select TriggerAndAction in the dropdown menu.
B. Click "+" beside the Select a module and add dropdown.
C. Click "+" beside the selected module dropdown.
D. Click the type dropdown and select NotificationCenterSubscribeEntityPicking trigger.
E. Click "+" beside the selected module dropdown.
F. Click the type dropdown and select a desired action. In this example, the EntityPlayAnimation action is selected. For the EntityPlayAnimation action to work, the name of the animation state that gets played needs to be added to the animate state to play field. In this example, the animation state name Jump
is added. The model that will be animated also needs to be added to the pick up specify execution entity field.