Non-Player Character (NPC) Plugin
Set Up
- Install the NPC Plugin from the marketplace into a space
- Add the plugin as a component to an object, like a Ready Player Me avatar model.
- In the object components, choose Update Script
- Enter a name and radius for the NPC to begin
- Use the script editor to write a script for the object to follow by adding actions
- Creator can use the text boxes next to each action in the script to enter an action number for the script to follow after a certain event. This is necessary when the NPC needs to react to user options.
Required Assets
1. NPC 3D Model
The NPC system is built around Ready Player Me avatars, and will utilize walk and run animations by default.
To get a GLB copy of a Ready Player Me avatar you have built, log into https://readyplayer.me/ and navigate to the Avatar Hub. We recommend creating an account with Ready Player Me to save your created avatars. Guide to download or use Ready Player Me Avatar models at the bottom of this article.
You can attach the NPC Plugin to any 3D Object and use the object's built-in animations.
2. Guide Outline & Avatar Story Dialogue
Where will your NPC avatar go? What will they say? Prepare the story and script of your NPC's journey. Use text popups and/or sound bytes to guide the experience.
Each Text Popup can hold ~500 characters maximum while also displaying an image.
Audio Soundbytes can also be played at each step of the script.
3. Images & Sounds
You can use custom images to guide each step of the story. Images display above the NPC text, whether it's an avatar image with a different emotion, a visual landmark, or a small informational graphic.
Audio and soundbytes can be played during any step of the script. Sounds play from the NPC avatar model. Record a separate audio clip for each soundbyte, and we recommend keeping audio clips short, under ~15 seconds.
Building your NPC Script
- In the NPC Script Editor, start by Naming your tour Guide and choosing the Radius they are first activated.
- Then Choose an Action.
- The first action must always be either 'Wait for User in Radius' or 'Wait for NPC click' actions in order to prevent unintentional looping.
- If your avatar moves during the script, we recommend ending the script with a movement back to the starting point.
- Set any required Action Attributes
- Choose "Add Action"
- "Save Script"
Editing your Script
To edit variables within your script, double-click the action and replace the variables in the text field.
NPC Properties
Name
- The name of the NPC character which will show up when you interact with it, and used with any Text. ex: "Pepper: Hi, would you like to take a tour of the space?"
Radius (in meters)
- The radius around the NPC that is seen as the interact/trigger area.
NPC Script Actions
Wait For NPC Click
- NPC waits for a user to click on it's object
Wait For User In Radius
- NPC waits for a user to be within the radius set in the properties or for the user to click on the NPC object.
Show Image Popup
- Add an image URL to represent the NPC in a UI popup
- Note: this image will stay as the image shown in interactive popups until a new "Show Image Popup" action is added to the script
- Upload images to Spaces Storage in order to copy a direct URL.
Show Text Popup
- Enter text that will be shown with the NPC image to communicate to the user with.
- The text will show in the popup until the user clicks on the image to dismiss it or moves out of interactable range.
Play Animation
- Select an animation to play. Select a default of walk, run or idle if you are using Ready Player Me NPC objects and user avatars, or choose a custom animation built into the object.
- The animation will continue to play until a 'stop animation' action is performed.
Stop Animation
- Stops any animation that the NPC character is playing
Play Audio
- Enter an audio url that will play from the NPC
Stop Audio
- Stops any audio that the NPC character is playing
Move NPC
- Moves the NPC from it's current position to a new coordinate
- A user can set the new position using the x,y and z coordinate fields, or move to the desired location and use the "User current postion" button to set the new location to the current user position.
- The duration field is the time in seconds it will take for the NPC object to move to the new location
Question
- Enter a question and up to 4 possible answers. The script creates a question action, and additional answer actions.
- The user will then be able to select one of the answers.
- When an option is selected, you can choose to jump forward or backward in the script by entering the Action number in the white text box in the script next to each question's answer.
Follow NPC
- The user will start following the NPC object. Useful in guided tours.
Unfollow NPC
- The user will stop following the NPC object.
Rotate NPC
- Rotate the NPC object by a user determined amount of degrees
Example Script
This example waits for the guest to walk up to or click on the NPC. The NPC says a "Hello" message and then asks if they would like to take a tour. If the guest chooses yes, the avatar will walk a short distance with the guest attached.
[
{"text":"[npc-click] Wait for user click [to: next]"},
{"text":"[npc-wait] Wait for user to be within 5 meters [to: next]"},
{"text":"[text-show] Hi there, thanks for stopping by! [to: next]"},
{"text":"[question] Would you like to go on a tour with me? [to: next]"},
{"text":"[answer] Yes, please! [to: next]"},
{"text":"[answer] No thanks. [to: 11]"},
{"text":"[follow] Follow the NPC [to: next]"},
{"text":"[play-animation] Play animation: humanoid.walk [to: next]"},
{"text":"[move-npc] Move NPC at a speed of 3 to coordinates: [225,0,-45] [to: next]"},
{"text":"[stop-animation] Stop animation [to: next]"},
{"text":"[unfollow] Unfollow the NPC [to: next]"},
{"text":"[text-show] That's it, please explore a bit more before you leave! [to: next]"},
{"text":"[move-npc] Move NPC at a speed of 3 to coordinates: [230.54730975312697,0.003906278014333081,-42.930512051517454] [to: next]"}
]
Downloading or copying Ready Player Me Avatar .glb file
- Log into Ready Player Me - https://readyplayer.me/
- Open your Avatar Hub
- Choose the 3 ellipses on the preferred avatar model to open the "more info" panel
- Choose "Copy .glb URL" to copy the url of the glb file. In Vatom Spaces, use "Import from URL" and paste this URL. This is the preferred method.
- Choose "Download avatar .glb" to download the GLB file of your avatar to your hard drive. In Vatom Spaces, use "Upload from File" and upload the file to your Storage.
To render still image PNGs of your avatar through Ready Player Me, use the "Pose" menu and disable the background image. Upload these images to your Spaces Storage to use throughout your NPC journey.
Comments
0 comments
Please sign in to leave a comment.