Remove Action

The Remove Action is used when we need to remove a specific object from the scene using our hands or a tool.

To generate a Remove Action you need the Interactable prefab (the one to be removed) and a hologram.

Remove object with hands

From the MAGES menu select the option CreatePrefab/Interactable

../../../_images/MenuInteractable.png

The Interactable prefab template will be instantiated. In this example we will remove a jar, thus we populate the prefab template with the jar model as seen in the image below.

../../../_images/RemoveInteractable.png

The only configuration we need is to set from the InteractablePrefabConstructor script the prefabInteractableType value to Remove It is also recommended to set the AttachPrefabSpawnNotifier value to True. This will set a flashing animation to the object, indicating its removal.

../../../_images/PrefabInteractableTypeRemove.png

Don’t forget to add proper physical colliders to the object.

Additionally, we generate an animated hologram showing a holographic hand removing the jar.

../../../_images/RemoveWithHandHologram.png

Finally, we save the prefabs in our LessonPrefab folder

../../../_images/RemoveWithHandSavedPrefabs.png

Action Script

The script below initializes the interactable prefab and spawns the hologram as well.

using MAGES.ActionPrototypes;
public class RemoveJarAction : RemoveAction
{
    public override void Initialize()
    {
        SetRemovePrefab("Lesson1/Stage0/Action3/JarRemove");

        SetHoloObject("Lesson1/Stage0/Action3/RemoveWithHandHologram");

        base.Initialize();
    }
}

Remove object with tools

In this case, we will remove three jars using a tool (the pliers) instead of our hands.

From the MAGES menu select the option CreatePrefab/Remove With Tools

../../../_images/MenuRemoveWithTool.png

This time we will generate three prefabs as seen below.

../../../_images/ThreeJars.png

Now, we will configure our remove prefabs to be removed with the pliers tool. At the RemoveWithToolsConstructor script which is attached to your prefab, set the RemoveTools size to 1 and from the dropdown menu select the tool you want. In this case we selected the Pliers. We will do the same configuration to all the three remove prefabs.

../../../_images/RemoveToolsPrefab.png

Additionally, we make an animated hologram.

../../../_images/RemoveToolsHologram.png

Finally, we save the prefabs in our LessonPrefab folder

../../../_images/RemoveWithToolSavedPrefabs.png

Action Script

In this Action we would like to remove three jars using the pliers instead of one, thus the Action script will be the following.

using MAGES.ActionPrototypes;
public class RemoveJarsWithPliersAction : RemoveAction
{
    public override void Initialize()
    {
        SetRemovePrefab("Lesson1/Stage0/Action3/JarRemove1");
        SetRemovePrefab("Lesson1/Stage0/Action3/JarRemove2");
        SetRemovePrefab("Lesson1/Stage0/Action3/JarRemove3");

        SetHoloObject("Lesson1/Stage0/Action3/RemoveWithPliersHologram");

        base.Initialize();
    }
}

Note

The above RemoveAction script sets three removable prefabs. In this case, the Action will Perform when all three are removed with the pliers.