Learn to grasp an object and use a tool.
In this article, we will introduce the Grasp and Use Tool Resources. We will also use several events:
We want to spray down the workbench. At this point, the workbench has two items on it: a jigsaw and a spray bottle.
Step 1: Create a new script
Click on the scroll icon in the upper right-hand corner of the screen and add a new script called "Spray Workbench".
Step 2: Add the Spray Workbench script to the Director Script
Before we edit our new script, we need to ensure that it will be run after the user successfully equips the hard hat in the scenario.
- Open the Director Script and add a new frame "Spray Workbench".
- Drag and drop the "Spray Workbench" script into the Resources:
- Ensure the "Spray Workbench" frame is open in the Director Script.
- From the Conditions menu, drag an "Object Event" condition into your conditions area.
- Script Object = Equip Hard Hat
- Event = Close
Step 3: Add an End Script Resource to the Equip Hard Hat Script
So we've determined that the Spray Workbench script should run after the Equip Hard Hat script has ended, so let's set up an end to the Equip Hard Hat script to ensure that our scenario proceeds properly.
For this scenario, we want the user to continue onto the next step once they have been notified that they have successfully equipped the hard hat.
- From the Notification within the "Equip Close" frame, click on the blue "+" Event Link button and select the "close" event.
- In the new frame, add an 'End Script' resource.
Once that has been added, the scenario will properly run the new 'Spray Workbench' script once the Equip Hard Hat script has completed.
Step 4: Rename the Frame
- Open the Spray Workbench script.
- Rename the frame called "New Frame" to "Scene Objects".
Step 5: Add the Spray Bottle and Jigsaw
We need to add two objects to the frame: Spray Bottle and Jigsaw.
- Click the Catalog icon on the far right and click on "Workshop Objects".
- Drag and drop the Spray Bottle into the Resources section of the frame.
- Drag and drop the Jigsaw into the same area.
- Drag and drop the Bench Top into the area as well.
- Save the script.
Step 6: Add a new Frame and Grasp the Jigsaw
- Add a new frame on the same level as the Scene Objects frame. Rename it "Pick up Jigsaw".
- Locate the Grasp resource (User picks up an item by grasping) and drag it into the frame.
- Select "Jigsaw" from the World Objects drop-down menu. From the Prompts menu select "Text".
- Once "Text" selected, a new text area will appear. Enter "Pick up the Jigsaw and hold it" or similar.
You can leave the Prompt Anchor blank. For this type of resource, it will use the Jigsaw (World Object) as the anchor by default unless you specify a different one.
Step 7: Create a New Frame with a Shortcut
We want the next step to happen once the user has picked up the Jigsaw and is holding it with one hand. Let's create a new frame once that action has happened.
- Click on the blue "+" Event Link button and select the "close" event at the bottom of the Grasp resource.
This will create a subframe of the "Pick up Jigsaw" frame. The new frame will have an Object Event condition with the script object "Jigsaw - Grasp" and an event "close".
- Rename the new frame "Pick up Spray Bottle".
- Save the script.
Step 8: Grasp the Spray Bottle
Just like we did with the Jigsaw, we need to pick up the Spray Bottle.
- From the resources menu, find the Grasp resource and drag it over to the frame.
- In the World Objects area, choose "Spray Bottle" (the item we want to pick up).
- In the Prompts dropdown, choose "Text". Enter in the text "Pick up the Spray Bottle" (to give the learner information on what to do).
The result should look like this:
The next step will happen after the learner has grasped the Spray Bottle.
- As usual, go to the bottom of the frame and click on the blue "+" icon and choose the event "close":
Step 9: Spray the Workbench
- Re-name the new frame "Spray Workbench".
- In the Resources section, find "Use Tool" and drag it into the frame.
- Inside the frame, set the following values in the Use Tool resource.
- World Object = Bench Top
- Use Tool = Spray Bottle
- Number of Times = 2
- Event = Complete
This means, spray the benchtop two times.
At this point, the user is holding the jigsaw in one hand and the spray bottle in the other. Whichever hand is holding the spray bottle can spray the surface of the workbench by using the controller.
Tip: Help the user by adding a text prompt to the spray bottle. Give them instructions on what to do with the bottle.
Step 10: Notify the User When Complete
When the benchtop has been sprayed the requisite number of times, we want to let the user know.
- Create a new frame by clicking the shortcut button at the bottom of the Use Tool resource. Select "complete" (NOT "close" as we've been previously choosing).
- Rename the frame "Spraying complete".
- Add a Notification resource.
- Enter "Job Well Done!!" in the message section.
- Add a sound from the Workshop Sound Effects catalog. Choose one of the two Notifications.
- Add an image from the Workshop Icons catalog. Choose the "Correct" icon.
- STOP: Save and test. This script prompts the user to pick up and hold the jigsaw, grab the spray bottle, and spray the workbench.
In the Headset
This is what your scenario will look like so far:
Key Takeaways from Tutorial 6
- Prompt Anchors can help you position your helpful hints/text to the learner so they know what to do. If you leave the anchor blank it will use the World Object by default unless you specify a different one.