# Unity - Procedural Scenario Creation

**URL:** https://discourse.kitware.com/t/unity-procedural-scenario-creation/882
**Category:** Pulse Physiology Engine
**Created:** [August 1, 2022, 6:33am UTC](https://discourse.kitware.com/t/unity-procedural-scenario-creation/882 "2022-08-01T06:33:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dhuang101](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/d/f475e1/32.png) [@dhuang101](https://discourse.kitware.com/u/dhuang101)
#### Post date: [August 1, 2022, 6:33am UTC](https://discourse.kitware.com/t/unity-procedural-scenario-creation/882/1 "2022-08-01T06:33:44Z")

</div>

Hello,

I am trying to create my own custom Scenario Driver in which the scenario is procedurally created at runtime instead of using one of the scenario files.  
To do this I have commented out the code which initialises the state file from the editor and the section which initialises from a specified path (lines 74-89) so that the code reaches the example given.  
Then, I altered line 94 and set the path of the StandardMale.json to StreamingAssets where it is contained.  
When running the scene it instantly crashes my Unity Editor and I am unsure why. I have attached a screenshot of my PulseEngineScenarioDriver.cs

 ![Screenshot 2022-08-01 162503](https://discourse.kitware.com/uploads/default/original/1X/42f1daa573ddbafda479cdc46664fd9a62fd3623.png)

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [August 1, 2022, 12:48pm UTC](https://discourse.kitware.com/t/unity-procedural-scenario-creation/882/2 "2022-08-01T12:48:00Z")

</div>

First thing I would do is check the [Unity Log](https://docs.unity3d.com/Manual/LogFiles.html), and [the Pulse Log](https://gitlab.kitware.com/physiology/unity/-/blob/master/Scripts/PulseEngineScenarioDriver.cs#L66)

See if that gives you some hints

---

<div class="post-metadata">

### Author: ![dhuang101](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/d/f475e1/32.png) [@dhuang101](https://discourse.kitware.com/u/dhuang101)
#### Post date: [August 2, 2022, 12:42am UTC](https://discourse.kitware.com/t/unity-procedural-scenario-creation/882/3 "2022-08-02T00:42:34Z")

</div>

The Unity Log shows that it is crashing on the InitializePatient function but nothing more.  
The Pulse Log on the other hand is showing that it cannot find the substance directory at “./” and I’m not sure where to put the substance directory so that the Pulse engine can find it.

 ![Screenshot 2022-08-02 104157](https://discourse.kitware.com/uploads/default/original/1X/11c14405000278fa1017b775fb11f7547ad77be5.png)

---

<div class="post-metadata">

### Author: ![dhuang101](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/d/f475e1/32.png) [@dhuang101](https://discourse.kitware.com/u/dhuang101)
#### Post date: [August 2, 2022, 3:44am UTC](https://discourse.kitware.com/t/unity-procedural-scenario-creation/882/4 "2022-08-02T03:44:10Z")

</div>

I also tried the “Creating a new patient section” in the Unity ReadMe and then using a scenario with a patient configuration instead of a state but the it looks like that section may be out of date as I get an error saying the InitializeEngine function does not take 3 arguments

 ![Screenshot 2022-08-02 134302](https://discourse.kitware.com/uploads/default/original/1X/6d073d7baa28889e083b4848f3a3fbc2e4fb365c.png)

![Screenshot 2022-08-02 133908](https://discourse.kitware.com/uploads/default/original/1X/a98412acfcd36b4d09c46579493778de698ea243.png)

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [August 2, 2022, 12:53pm UTC](https://discourse.kitware.com/t/unity-procedural-scenario-creation/882/5 "2022-08-02T12:53:54Z")

</div>

Sounds like the same problem as this

> [@Unity Running Scenario: Unable to initialize patient](https://discourse.kitware.com/t/unity-running-scenario-unable-to-initialize-patient/872/8):
>
> I assume you are doing sometihng [like this](https://gitlab.kitware.com/physiology/unity/-/blob/master/Scripts/PulseEngineScenarioDriver.cs#L131) I think Pulse is failing to [find the data files it needs from disk](https://gitlab.kitware.com/physiology/engine/-/wikis/how%20to%20connect%20to%20pulse#application-execution) Try adding this line before your InitializeEngine call: scenario.GetPatientConfiguration().SetDataRootDir(Application.streamingAssetsPath+"/Data/"); Those directories should be under that Data folder Hopefully Pulse will then be able to find the files its looking for
