Use Action

In a Use Action, the user should take an object and interact with it over an area (collider) or another object. An example can be the sterilization of a wound.

../../../_images/new_use_action.gif

How to Setup a Use Action

In this tutorial we will make a use action to apply disinfectant to a cotton ball.

  1. Right-click on the scenegraph editor.

  2. Select New Action > Use Action.

../../../_images/use_action_creation.png
  1. Create the Use Object. This is the disinfectant that we will take and apply it over the cotton ball. This object will spawn when the Action initializes.

../../../_images/use_action_object.png

Note

It’s important to add physical colliders to the object. The colliders refer to the Collider Component that you can add to your object by clicking the Add Component button in the inspector of your prefab or GameObject. It’s crucial to use the appropriate colliders and adjust them to match your GameObject’s shape.

../../../_images/collider_component4.png
  1. Save the use object as a prefab to your assets and drag it to the Use Object field in the Action node.

../../../_images/use_action_object_node.png

Note

To save the Insert Object as a prefab, drag the object from the Scene Hierarchy in your Unity Editor and place it inside your Assets. It is strongly advised to place your prefabs under a Resources folder. For example, in our case: Assets > Samples > MAGES - Core > 1.0.0 > Example Scene > Resources > Prefabs > AlcoholBottle.

  1. Now it is time to setup the Use Collider. This is the second object that will interact (touch) the use object to complete the Action. As a use collider we will use a cotton ball model. We will spawn it next to the disinfectant.

../../../_images/use_action_collider_object.png

Note

Its important to add physical colliders to the use collider object, following the same procedure as the Use Object.

  1. Save the use collider as a prefab to your assets. Drag and drop it to the Use Collider field in the Action node.

../../../_images/use_action_collider_node.png

Note

For the use collider you can also use a simple collider without any renderer. This is also useful in some cases.

  1. Name the action, e.g., “Pour Alcohol on cotton ball”.

See also

You can set the Use time to configure the number of seconds you need to have the two objects in contact to perform the Action. In our example we set it to one second.

To perform the action instantly when the objects collide, set its value to zero.

  1. Remove any prefabs you created from the scene and save the scenegraph.

How to Perform

The Action performs when the user takes the disinfectant and the cotton ball and brings them into contact for 1 second.

Video tutorial