-
Notifications
You must be signed in to change notification settings - Fork 5
SimulationObjects
In PDSim you can customise PDDL types to create your own GameObject that represent an object. This is done by personalising the PdSimSimulationObject component that is automatically generated for each 'leaf' type in the type hierarchy. If no PDDL user type is defined, the PdSimSimulationObject component is generated for the object type.
For example the image below show the customization of the types for a simplified warehouse domain.
To customise a simulation object, navigate in the project folder under _Simulations > *Simulation Name* > Objects.
For example, the image below show where to find the van object.
- Expand the current simulation folder named after what you have specified as simulation name when creating a new scene (Getting Started).
- Double click on the object you want to customise. This will open a
prefab editorin the scene view.
- The main scene view.
- The root of the prefab, in this case the
truckobject. This is the object that will be instantiated in the scene when the simulation is run. Click on thetruckobject to select it, the inspector will show thePdSimSimulationObjectcomponents (3,4,5). - The
PdSimSimulationObjectcomponent. - The
RigidBodycomponent. This is automatically added to the object and set asKinematicto allow the object to be moved by the simulation. - The
Box Collidercomponent. This is automatically added to the object to allow the object to interact with other objects in the scene. - The variables of the simulation object. These are the variables that can be used in the animation graph to animate the object. These are automatically populated to hold references of the points and models of the object.
- The Script Machine component. You can use this to create a custom logic that runs when you presse the play button.
The user can add components to the object variables to customise the object. For example, in the image the truvk object has several Mesh Renderer components to represent the wheels, the body and the door (point 2). The image below shows the components of the body of the van model. To add the Mesh Renderer component to the object variables, click on the Add To Variables button in the inspector as highlighted in the image.
This will add the Mesh Renderer component selected to the object variables as shown in the image below. You can then use this in the animation graph to animate the object.
The PdSimSimulationObject component is automatically added for each object in the simulation. This shows the PDDL type attached to the object.
You can check Use Nav Mesh Agent to tell PDSim to execute every movement (with the provided nodes) using Unity's pathfinding system. This is useful if you want to use the Translate To Object or Translate To Point nodes to move the object around the scene (see: Animations).
You can provide a movement setting file to the Movement Settings field. You can create a new movement setting file by right clicking in the project folder and selecting Create > PDSim Agents. This will create a new movement setting file that you can edit in the inspector. If you click on the new create file the inspector will show the following:
-
Speed: the speed of the agent. -
Angular Speed: the angular or turning speed of the agent. -
Acceleration: the acceleration of the agent. -
Stopping Distance: the minimum distance from the target at which the agent will stop. -
Face Target: if true the agent will face the target when it reaches it.
Note: If no movement setting file is provided, the agent will use the default settings.
After the user added the components to the object variables, the user can create a custom logic that runs when the simulation starts, or when a predicate is added in the animation queue during the simulation. This is done by creating a custom logic in the Script Machine component.
Example: Change random color of the van body on start.
Click on the Edit Graph button to open the animation graph editor. The new window will show the following:
This Script machine differs from the animation as is not populated with PDSim events (see: Animations). This is because the script machine is bound to the simulation object itself and not to a predicate.
The event On Start is triggered when the simulation starts. The example use the change random color node provided by PDSim to change the color of the van body on start. The van body mesh is accessed using the node Get Variable that is automatically created if you drag and drop the variable in the graph editor.