跳转至

Demo Project

约 4087 个字 预计阅读时间 14 分钟

The following article details the process of setting up the asset bundle and scenario shipped as part of the demo projects of 3D PACT.

Resources:

Below you can download the completed source facility, asset bundle and scenario.

Resource Download
Combined Cycle Unity Package .unitypackage
Combined Cycle Asset Bundle .bundle
“Extinguish Fire & Evacuate“ Scenario .scenario

The following links outline how to upload them to the 3D PACT Management Systems (MS) and import them into the 3D PACT Instructor Station and execute the scenario in the 3D PACT Trainee Station


Scenario Objective

In the Combined Cycle Facility, spawn the participant in as well as 3 Non Player Characters (NPCs). The NPCs should be made to walk to designated locations of your choice. Create Tasks in which the participant needs to identify the value and open it. A fire particle system is then triggered. The user should then be tasked with identifying the fire, retrieving and activating the fire extinguisher, extinguishing the fire. Once extinguished, the participant and all 3 NPCs should move to the designated evacuation point, after which the scenario is concluded.

The Approach

Step 1: Configuring the Facility

Step 1.1: Create a New Unity Project

  • Launch Unity Hub

  • Click “New project“

  • Ensure you select the Unity Editor Version 2022.2.24f1

  • Give your Project a name, like “Combined Cycle“

  • Optional: Link your project to a Version Control System (VCS), like Plastic, GitHub etc.

  • Click “Create project“

Step 1.2: Install the 3D PACT Engineer Station (ES) Package

  • In the Unity Project, click AssetsImportCustom Package...

  • Find your local copy of the 3D PACT Engineer Station (ES) Package and click Open

    • If you don't have one, download it here:
  • Allow some time for the import to complete

  • Once complete, in the toolbar, you will see an Engineer menu option

Step 1.3: Import the Combined Cycle package

  • In the Unity Project, click AssetsImportCustom Package...

  • Find your local copy of the Combined Cycle Unity Package and click Open

    • If you don't have one, download it here:
  • Allow some time for the import to complete

  • Once complete, you should see the Combined Cycle Scene

Step 1.4: Configure the Valve and Fire Particle System

For more information on how to set up Interactables, seeCreating Interactables.

Configure the Valve

  • Locate the Valve model in the Hierarchy

  • Add to the Valve Game Object:

    • An Interactable Visual component

    • A Collider

  • Navigate, in the Project folder, to AssetsClientFilesPrefabsInteraction States and drag the Rotate State prefab into the Hierarchy

image.png

  • On the Interactable Visual component of the Valve:

    • Drag the Rotate State prefab into the State Objects array

    • Optionally drag the Valve’s Mesh Renderer into the Interaction Affordance Renderer variable

image.png

  • Next, we will set up the Valve to switch between opened and closed states, so that scenarios can check if a Trainee has performed either action. See Visual Scripting Interactable Logic for more detail on Visual Scripting

  • Add a State Machine component to the Valve

  • Click the 'New' button:

    • Name the State Graph ‘Valve’

    • Save the State Graph to the ‘Graphs’ folder

  • Click the 'Edit Graph' button

  • Double-click on the ‘Start’ node and remove everything except for the ‘On Enter State’ node

  • Right-click and search for ‘Interactable Visual Set State’ and choose the first option to set the state name to ‘Idle’

image.png

  • Navigate out of the ‘Start’ node by clicking on the ‘Valve’ State Graph tab on the top left

image.png

  • Right-click and select ‘Create Script State' and rename it to 'Opened’ in the Graph Inspector on the left

  • Double-click on the Script State and again remove all nodes except for the On Enter State node

  • Right-click and search for ‘Interactable Visual Set State’ and choose the first option to set the state name, this time to ‘Opened’

  • Copy your ‘Opened’ Script State node (right-click copy and paste)

  • Rename the new Script State to ‘Closed’ in the Graph Inspector and, inside the Script State, rename the state name to ‘Closed’

  • Now that all states are set up, it’s time to create the Transitions between them

  • Right-click on the ‘Start’ node, select ‘Make Transition’, and click on the ‘Opened’ node

  • Repeat this step to make Transitions from ‘Start’ to ‘Closed’, from ‘Opened’ to ‘Closed’, and from ‘Closed’ to ‘Opened’

image.png
- Double-click on the Transition from ‘Start’ to ‘Opened’ to edit it

  • Trigger the Transition when the rotation progress has reached ‘Start’ (the minimum rotation limit) using a Custom Event ‘Progress Changed’. For more information on progress tracking and the Rotate State, see Interactable States.

image.png

  • Copy and paste these nodes inside all Transitions

  • In the Transitions pointing to ‘Closed’ ('Start' → ‘Closed’ and ‘Opened’ → ‘Closed'), changed the ‘Progress’ variable to ‘End’ to check when the progress has reached ‘End’ (the maximum rotation limit)

image.png

  • The Valve will now change its state name to ‘Opened’ when it is turned all the way to the left and ‘Closed’ when it is turned all the way to the right - this means that the Scenario Editor can check when the Valve has been opened or closed

Configure the Fire Particle System

  • Navigate in the Project folder to Assets_ProjectPrefabsFires and drag and drop the desired fire particles prefab into the scene

  • Create an empty Game Object and name it ‘Fire’

  • Move the fire particles prefab into the ‘Fire’ Game Object and reset its Transform

  • To the ‘Fire’ Game Object, add an Interactable Visual component and a Collider

  • Resize the Collider to encapsulate the fire particles

Step 1.5: Configure the Gaze Interaction for the Fire Particle System

Configure the Fire Particle System Logic

  • Navigate, in the Project folder, to AssetsClientFilesPrefabsInteractable States

  • Drag the Gaze State prefab into the Hierarchy and rename it to ‘Fire Gaze State’

image.png

  • Drag the ‘Fire Gaze State’ Game Object into the State Objects array on the Interactable Visual component of the 'Fire' Game Object

  • Add a State Machine component to the ‘Fire’ Game Object

  • Click the 'New' button:

    • Name the State Graph ‘Fire’

    • Save the State Graph to the ‘Graphs’ folder

  • Click the 'Edit Graph' button

  • The goal of the Fire logic is to:

    1. Spawn the Fire particles when the Valve is opened

    2. Set its state name to ‘Located’ when the user looks at the Fire - this is the purpose of the Gaze State

    3. Decrease the Fire’s health and number of particles while the Extinguisher is being used

    4. Set the Fire’s state name to ‘Put Out’ when its health reaches 0

    5. Hide the Fire and reset its health and particles (in case it needs to spawn again)

  • Double-click on the ‘Start’ node, rename it to ‘Inactive’, and remove everything except for the ‘On Enter State’ node

  • Right-click and search for ‘Interactable Visual Set State’ and choose the first option to set the state name to ‘Inactive’ - the Fire has not yet spawned

image.png

  • Navigate out of the ‘Inactive’ node by clicking on the ‘Fire’ State Graph tab on the top left

  • Right-click and select ‘Create Script State' and rename it to 'Active’ in the Graph Inspector (on the left)

  • Repeat this last step to create Script States for ‘Reset Fire’, ‘Located’, and ‘Put Out’

  • Make Transitions from ‘Start’ → ‘Reset Fire’, ‘Reset Fire’ → ‘Active’, ‘Active' → ‘Located’, ‘Located’ → ‘Put Out’, and ‘Put Out’ back to 'Reset Fire’

image.png

  • On the Variables component of the Fire Game Object, create two float Object Variables ‘Start Health’ and ‘Current Health’

image.png

  • Inside the ‘Reset Fire’ node, we need to reset the maximum particles for each Particle System of the Fire

    1. Create a list of Particle System Object Variable called ‘Particles’ and drag in all of the Fire Particle Systems

image.png

  • Create a list of float Graph Variable called ‘Max Particles’

image.png

  • Now, initialize the ‘Max Particles’ Graph Variable to the actual max particles of each Particle System in the ‘Particles’ Object Variable by creating a Custom Event node called ‘Set Max Particles’

image.png

  • Next, create another Custom Event ‘Reset Particles’ to reset the max particles of each Particle System in the ‘Particles’ Object Variable to the floats in the ‘Max Particles’ Graph Variable. This event can now be called whenever the Fire’s particles need to be reset after being extinguished

    1. Finally ‘On Enter State’, trigger the Custom Events, set isTrigger on the Collider to false so that the fire can be selected with Gaze State, and initialize ‘Current Health’ to ‘Start Health’

image.png

  • Inside the ‘Active’ node, simply set the state name to ‘Active’

image.png

  • Inside the ‘Located’ node, set the state name to ‘Located’ and set isTrigger on the Collider to true so that the Collider can no longer be selected with Gaze State

image.png

  • Inside the ‘Put Out’ node, set the state name to ‘Put Out’

image.png

  • Now we need to set up the Transitions between the states

  • Create another Object Variable ‘Main Particles’ and drag in the parent Particle System

image.png

  • ‘Inactive’ → ‘Reset Fire’: the Fire particles should reset each time the Fire is spawned, so we will create a ‘Spawn Fire’ Custom Event to Transition from ‘Inactive’ to ‘Reset Fire’. The Valve can then call this event when opened, and that will trigger the transition to reset the Fire

image.png

  • ‘Reset Fire' → ‘Active’: nothing needs to happen, so the Transition can automatically trigger

Open Screenshot 2024-07-25 115304.png

image.png

  • ‘Active’ → ‘Located’: wait for the ‘Hover Entered' event on the Gaze State to check if the user has looked at the Fire

image.png

  • ‘Located’ → ‘Put Out’: reduce the Fire health and particles when it is being extinguished

    • First, we need to define emission constants for each Particle System - at what rate should each Particle System reduce its particle count, such that all particles are diminish at the same time? Create a list of float Graph Variable ‘Emission Constants’

image.png

  • Set the each item in ‘Emission Constants’ Graph Variable to the max particles of each ‘Particles’ Object Variable divided by ‘Current Health’

image.png

  • Wait for the ‘On Ray Entered’ Custom Event to be called from the Extinguisher (when the Extinguisher is pointing at the Fire), and reduce the Fire’s health and the number of particles of each Fire Particle System in the ‘Particles’ Object Variable

image.png

  • ‘Put Out’ → ‘Reset Fire’: copy ‘Spawn Fire’ Custom Event nodes from the ‘Inactive’ → ‘Reset Fire’ Transition to reset the Fire after it's been put out whenever the ‘Spawn Fire’ event is called

Step 1.6: Configure the Fire Extinguisher and interaction with Fire Particle System

Configure the Fire Extinguisher

  • Search the Project folder for the extinguisher model and drag and drop it into the Hierarchy

  • Rename the model to ‘Extinguisher’

  • To the ‘Extinguisher’ Game Object, add an Interactable Visual component and a Collider

  • Navigate, in the Project folder, to AssetsClientFilesPrefabsInteractable States

  • Drag the Grab State prefab into the Hierarchy and rename it to ‘Extinguisher Grab State’

image.png

  • Drag the ‘Extinguisher Grab State’ Game Object into the State Objects array of the Interactable Visual component

  • The Extinguisher is now grabbable

Configure the Fire Extinguisher Logic

  • Add a State Machine component to the Extinguisher

  • Click the 'New' button:

    • Name the State Graph ‘Extinguisher’

    • Save the State Graph to the ‘Graphs’ folder

  • Click the 'Edit Graph' button

  • The goal of the Extinguisher logic is to:

    1. Set the state name when it is grabbed and released

    2. When the trigger key is pressed, play Extinguisher particles and shoot a ray to detect if the particles are hitting a Collider (the Fire)

    3. Stop the particles and reset the ray when the trigger key is released

    4. Create Custom Events ‘On Ray Enter’ and ‘On Ray Exit’ to call in the Fire logic

  • Double-click on the ‘Start’ node and remove everything except for the ‘On Enter State’ node

  • Right-click and search for ‘Interactable Visual Set State’ and choose the first option to set the state name to ‘Idle’

image.png

  • Navigate out of the ‘Start’ node

  • Right-click to ‘Create Script State' and rename it to 'Grabbed’ in the Graph Inspector (on the left)

  • Copy the ‘Grabbed’ script state 3 times and rename each to ‘Released’, ‘Start Spray’, and ‘Stop Spray’

  • Next, make Transitions between ‘Start’ → ‘Grabbed’, ‘Grabbed’ → ‘Released’, ‘Released’ → ‘Grabbed’, ‘Grabbed’ → ‘Start Spray’, ‘Start Spray’ → ‘Stop Spray’, ‘Stop Spray’ → ‘Start Spray’, ‘Start Spray’ → ‘Released’, and ‘Stop Spray’ → ‘Released’

image.png

  • Inside the ‘Grabbed’ node, set the state name to ‘Grabbed’

image.png

  • Inside the ‘Released’ node, set the state name to ‘Released’

image.png

  • For the spraying logic, we will need to create some Object Variables: ‘Ray’ (to detect if the spray is hitting the fire), ‘Spray Particles' (the spray Particle System), and the ‘Nozzle’ (where the ‘Ray’ and particles should shoot from)

image.png

  • Inside the ‘Start Spray’ node, first create the ‘On Ray Enter’ and ‘On Ray Exit’ Custom Events

image.png

  • Next, ‘On Enter State’, trigger the ‘On Ray Enter’ Custom Event and play the ‘Spray Particles’

image.png

  • Now we need to set the Ray’s position to the ‘Nozzle’ in a forward direction, and check if it hits anything

    1. First, create two Collider type Graph Variables ‘Hit’ and ‘Last Hit' to check each frame if the Ray has entered a new Collider

image.png

  • Create the Ray and, every frame ('On Fixed Update'), set its position to the Nozzle position and its direction to the direction in which the Nozzle is pointing (forward)

image.png

  • Check if the Ray has hit a Collider

image.png

  • If it has hit a Collider, if the Collider that was hit ('Hit') is not the same as the Collider that was previously hit ('Last Hit'), trigger the ‘On Ray Enter’ Custom Event arguments and finally set ‘Last Hit’ to ‘Hit’

image.png

  • Otherwise, if no Collider was hit, set ‘Hit' to null. If the Collider that was previously hit (‘Last Hit’) exists, trigger the ‘On Ray Exit’ Custom Event arguments and finally set ‘Last Hit’ to ‘Hit’

image.png

  • The full graph to shoot the Ray and detect collisions connects as follows:

image.png

  • Inside the ‘Stop Spray’ node, trigger the ‘On Ray Exit’ Custom Event arguments, reset the position and direction of the Ray, and stop playing the Spray Particles Particle System

image.png

  • Now we need to set up the Transitions:

    1. For the Transitions to ‘Grabbed’ (from ‘Start’ → ‘Grabbed’ and ‘Released’ → ‘Grabbed’), wait for the ‘Select Entered’ Custom Event

      image.png

    2. For the Transitions to ‘Released’ (from ‘Grabbed’ → ‘Released’, ‘Start Spray’ → ‘Released’, and ‘Stop Spray’ → ‘Released’), wait for the ‘Select Exited’ Custom Event
      image.png

    3. For the Transitions to ‘Start Spray’ (from ‘Grabbed’ → ‘Start Spray’, and ‘Stop Spray’ → ‘Start Spray’), wait for the ‘Activated’ Custom Event, which checks when the trigger key is pressed

      image.png

    4. For the Transition to ‘Stop Spray’ (from ‘Start Spray’ → ‘Stop Spray’), wait for the ‘Deactivated’ Custom Event, which checks when the trigger key is released

      image.png

Step 1.7: Test the Environment Logic

  • Search the Project folder for ‘XR Interaction Hands Setup’

  • Drag and drop the ‘XR Interaction Hands Setup’ into the scene and position it near your Interactables

  • Enable Quest Link in your headset

  • Click the Unity ‘Play’ button

  • You will now be able to interact with your Interactables in VR

  • Make sure you remove the ‘XR Interaction Hands Setup’ prefab from your scene before exporting

Step 1.8: Login and Export the Asset Bundle to the 3D PACT Management System

  • In the Unity Project, in the tool bar click EngineerImport/Export

  • In the window, enter your 3D PACT Management System Tenant Name, Username and Password

    • NOTE: This user account should have the minimum permissions of an Engineer User

    • Don’t know these details? Read more here: [User Guide - 3D PACT Management System (MS)]

  • In the window, click ExportNew

  • Select an appropriate Company & Facility

    • Don’t know what these are? Read more here: [User Guide - 3D PACT Management System (MS)]
  • Give the Asset Bundle a name, description and select the Locked option

    • What's the difference? Read more here: [User Guide - 3D PACT Management System (MS)]
  • Allow some time for the Export to take place. Keep track of progress through the Editor Console

    • What is going on behind the scenes? Read more here: [User Guide - 3D PACT Engineer Station (ES)]

Step 2: Creating & Testing the Scenario

Step 2.1: Login into 3D PACT Instructor Station and create a New Scenario

  • Open the 3D PACT Instructor Station (IS), enter your 3D PACT Management System Username and Password

    • Don’t know these details? Read more here: [User Guide - 3D PACT Management System (MS)]

    • Your first time using IS? Read more here: [Installation Guide - 3D PACT Instructor Station (IS)]

  • On the Scenario Type window, clock New

  • Select the Company, Facility and Asset Bundle you created in Step 1.8, and click Next

  • In the New Scenario window, enter a Scenario Name (like “Extinguish Fire & Evacuate“) and an optional description

  • Allow some time for the Asset Bundle to be downloaded from 3D PACT Management System (MS) and imported into 3D PACT Instructor Station (IS)

  • Once complete, you will be presented with the Scenario canvas

Step 2.2: Add a Spawn Point for the Participant

  • In the toolbar of IS, click the Facility Tab

  • Navigate to the general area where you would like to add the Spawn Point

    • How do I navigate? Read more here: [User Guide - 3D PACT Instructor Station (IS)]
  • Using your mouse, right click and select CreateMarkerPlayer Spawn Location

  • Select the “Move” transform gizmo, and fine tune the position of the Spawn Point

    • What is the transform gizmo? Read more here:

    • I cant see the Spawn Point?

      • TIP: press the F key on your keyboard to automatically move to have the object in view

Step 2.3: Add Spawn Points for the NPCs

  • In the toolbar of IS, click the Facility Tab

  • Navigate to the general area where you would like to add the Spawn Point

    • How do I navigate? Read more here: [User Guide - 3D PACT Instructor Station (IS)]
  • Using your mouse, right click and select CreateMarkerNPC Spawn Location

  • Select the “Move” transform gizmo, and fine tune the position of the Spawn Point

    • What is the transform gizmo? Read more here:

    • I cant see the Spawn Point?

      • TIP: press the F key on your keyboard to automatically move to have the object in view
  • Repeat the above steps for the other two NPCs

Step 2.4: Add Waypoints for the first and evacuation target location for NPCs

  • In the toolbar of IS, click the Facility Tab

  • Navigate to the general area where you would like to add the first NPC Waypoint

    • How do I navigate? Read more here: [User Guide - 3D PACT Instructor Station (IS)]
  • Using your mouse, right click and select CreateMarkerNPC Waypoints

  • Select the “Move” transform gizmo, and fine tune the of the first NPC Waypoint

    • What is the transform gizmo? Read more here:

    • I cant see the Spawn Point?

      • TIP: press the F key on your keyboard to automatically move to have the object in view
  • Repeat the above steps for the other two NPCs

  • Navigate to the general area of the designated evacuation point

    • How do I navigate? Read more here: [User Guide - 3D PACT Instructor Station (IS)]
  • Using your mouse, right click and select CreateMarkerNPC Waypoints

  • Select the “Move” transform gizmo, and fine tune the of the evacuation NPC Waypoint

    • What is the transform gizmo? Read more here:

    • I cant see the Spawn Point?

      • TIP: press the F key on your keyboard to automatically move to have the object in view
  • Repeat the above steps for the other two NPCs

Step 2.5: Configure your NPC Templates

  • In the toolbar of the IS, click the Character Editor tab

  • In the window click Create New

  • In the left panel, give the NPC a name, select a gender and ethnicity

  • In the right panel, configure the NPC’s PPE to your liking

  • In the bottom left corner, click Save Character

Step 2.6: Configure the Scenario logic

  • In the toolbar of the IS, click the Scenario tab

  • Optional: Click the Start Node, and in the Inspector, enter text and link a document and/or video to be displayed to the user prior to execution

  • Step 2.6.1: Spawn NPCs

    • On a blank part of the Node Canvas, right click and select CoreNPCSpawn

    • Connect the output of the Start Node to the input of the NPC Spawn Node

    • Click on the NPC Spawn Node and in the inspector on the right:

      • Click Add Group

      • In the newly created Group 1, click on the field next to NPC Spawn Point. This will open the facility view. Navigate and select the NPC Spawn Point you wish to use, and click Confirm Selected

      • Below the NPC Instance section click the + button. In the dropdown that appears on the left, select the NPC Template you wish to use. In the field on the right, enter a tag for the NPC

        • TIP: A NPC’s tag needs to be unique as it is used to refer to that specific NPC throughout the scenario
      • Repeat the previous 3 steps for the remaining NPCs

  • Step 2.6.2: Spawn the Participant

  • Step 2.6.3: Make NPCs move to first positions

  • Step 2.6.4: Create Task to Open the Value

  • Step 2.6.5: Create Task to Locate the Fire

  • Step 2.6.6: Create Task to Close the Valve

  • Step 2.6.7: Create Task to Pick up the Fire Extinguisher

  • Step 2.6.8: Create Task to Extinguish the Fire

  • Step 2.6.9: Make NPCs move to the evacuation point

  • Step 2.6.10: Create Task to move to the Evacuation Point

  • Step 2.6.11: End the Scenario

Step 2.7: Test the Scenario in Play Mode

  • In there center of the top of the screen, locate the Play Mode controls

  • In the dropdown on the left, make sure “VR“ is selected

  • Click the ▶️ button

    • This will start an emulator of what a user would see in the Trainee Station
  • Click Tutotial

  • On the Briefing screen, click START

  • If at any point you wish to stop Play Mode, click the ⏹️ button

Step 2.8: Export the Scenario to the 3D PACT Management System (MS)

  • In the top right corner, click FileExport

  • Select the Scenario option

  • Click Next

  • The scenario will then be uploaded to 3D PACT Management System (MS)

Step 3: Assigning the Scenario for Execution

Step 3.1: Open the 3D PACT Management System (MS) website and login

  • Open your web browser (e.g. Google Chrome), and navigate to your Tenant’s site

    • The format of the URL is: https://<insertyourtenant>.simgenics.cloud
  • Login with your 3D PACT Management System Credentials

    • NOTE: This user account should have the minimum permissions of an Instructor User

    • Don’t know these details? Read more here: [User Guide - 3D PACT Management System (MS)]

Step 3.2: Assign the Scenario to a User for execution

  • In the side navigation bar, click Facilities

  • In the facility view, locate the appropriate facility, then click ActionsView

  • Click on the Scenarios tab

  • Locate the appropriate Scenario, then click ActionsAssign To User

    • TIP: Don't see the option Assign To User? Make sure that the Scenario is Locked & Active
  • In the Role dropdown, select an appropriate option (e.g. Trainee)

  • In the User dropdown, select an appropriate option (e.g. A colleague or yourself)

  • Set the rest of the assignment parameters to your preference

    • Don't know what some of these fields mean? Read more here: [User Guide - 3D PACT Management System (MS)]
  • Click Save

  • OPTIONAL: To confirm that the assignment was made, click AssignmentsActive Assignments in the side navigation bar. You can then look for your assignment and manage it by clicking ActionsEdit

Step 4: Executing the Scenario

Step 4.1: Login into 3D PACT Trainee Station and select the Scenario Assignment

  • Open the 3D PACT Trainee Station (TS), enter your 3D PACT Management System Username and Password

    • Don’t know these details? Read more here: [User Guide - 3D PACT Management System (MS)]

    • Your first time using TS? Read more here: [Installation Guide - 3D PACT Trainee Station (TS)]

Step 4.2: Select an Execution Mode and and execute the Scenario

  • In the list of Assignments, select the appropriate record and then click Next

  • Allow some time for the Asset Bundle and Scenario to be retrieved

  • On the Briefing screen, click START

  • Continue to execute the Scenario

  • On completion, the TS will generate a Results PDF and upload it to the 3D PACT MS

Step 4.3: Confirm the Execution Results were saved in the 3D PACT Management System (MS)

  • Open your web browser (e.g. Google Chrome), and navigate to your Tenant’s site

    • The format of the URL is: https://<insertyourtenant>.simgenics.cloud
  • Login with your 3D PACT Management System Credentials

    • NOTE: This user account should have the minimum permissions of an Instructor User

    • Don’t know these details? Read more here: [User Guide - 3D PACT Management System (MS)]

  • In the side navigation bar, click Results

  • In the Results list, find the appropriate Result

  • You can access the following functionality by clicking Actions

    • View: see more details of the execution

    • Edit: change certain details about the result

    • Download: download the Results PDF to your local machine