Use Action

Use Action is similar to a Tool Action but instead of a tool we use another object to complete the Action.

Example of Use Action Script:

public class CleanKnossosAction : UseAction {
    public override void Initialize()
    {
        SetUsePrefab("AlternativeLessonPrefabs/SponzaRestoration/Stage0/Action0/cloth", "AlternativeLessonPrefabs/SponzaRestoration/Stage0/Action0/Dust");

        SetPhysicalColliderPrefab("AlternativeLessonPrefabs/AsinouRestoration/Stage0/Action0/PhysicalCollider");
        SetHoloObject("AlternativeLessonPrefabs/AsinouRestoration/Stage0/Action0/Hologram/hologram_clotha");

        base.Initialize();
    }
}

Action Script Explanation

  1. SetUsePrefab(string arg1, string arg2)

    1.1.Sets the prefab user needs to take and place it on the use collider to perform the Action.

    1.2. Sets the collider that the ‘UsePrefab” will interact to complete the action.

  2. Collider Prefab Constructor

Prefab Use Collider

An important setting you have to configure when creating a Use Action script is the amount of time the use prefab needs to interact with the use collider to Perform the Action. You can set this variable at “Stay Time” serializable field at the use collider prefab constructor (Use Collider Prefab).

Adding More to it

A more advanced example is the following:

public override void Initialize()
{
    //Set the interactable prefab which user will take and use it (touch collider) to perform the Action (1st argument)
    //Sets the collider which triggers the use Prefab. For more customization (CollisionStay time toperform) see prefab constructor(Unity editor) (2nd argument)
    SetUsePrefab("AlternativeLessonPrefabs/SponzaRestoration/Stage0/Action0/cloth", "AlternativeLessonPrefabs/SponzaRestoration/Stage0/Action0/Dust");
    //Sets physical colliders that will spawn on initialize
    //For this Action we need extra non triggered colliders since the model of Sponza dont have by default
    //These collider will be destroyed after perform/ Undo
    SetPhysicalColliderPrefab("AlternativeLessonPrefabs/SponzaRestoration/Stage0/Action0/PhysicalCollider");
    //Sets the hologram for current Action
    SetHoloObject("AlternativeLessonPrefabs/SponzaRestoration/Stage0/Action0/Hologram/hologram_clotha");
    //Sets action's AidLine text
    SetAidLine("AidLine_ClothGrab");

    sponzaHandLock = Spawn("AlternativeLessonPrefabs/SponzaRestoration/Stage0/Action0/SponzaHandLock");

    base.Initialize();
}