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
How to Setup a Use Action¶
In this tutorial we will make a use action to apply disinfectant to a cotton ball.
Right-click on the scenegraph editor.
Select
New Action > Use Action
.
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.
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.
Save the use object as a prefab to your assets and drag it to the Use Object field in the Action node.
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
.
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.
Note
Its important to add physical colliders to the use collider object, following the same procedure as the Use Object.
Save the use collider as a prefab to your assets. Drag and drop it to the Use Collider field in the Action node.
Note
Save the use collider object as a prefab by following the same procedure as the Use Object.
Note
As a use collider you can also use a simple collider without any renderer. This is also useful in some cases.
Name the action, e.g., “Pour Alcohol on cotton ball”.
See also
You can set the Use time to configure the amount of seconds you need to have the two objects in contact to perform the Action. In our example we set it to one second.
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.