# Dynamic Information Context

The **Dynamic Information** feature enables you to pass variables to NPCs in real time, allowing them to react dynamically to changes in the game environment. This can include the player’s current health, inventory items, or contextual world information, greatly enhancing interactivity and immersion.

## **Step-by-Step Guide to Setting Up Dynamic Config**

Firs&#x74;**, Add the Dynamic Info Controller** Component to your Convai NPC.

<figure><img src="https://413558230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FPcHnRayiITO9VCbTa8gk%2FUnity_DynamicInfoControllerComponent.png?alt=media&#x26;token=dc8daf1e-53e7-435b-9b12-7b2cdddb7a5c" alt=""><figcaption></figcaption></figure>

Create a new script or use an existing script to define a variable that will store a reference to the **Dynamic Info Controller** Component you added to your NPC.

### **Example: Passing Player Health to the NPC**

* **Initialize the Dynamic Info**: In the script’s **Start** method, call the `SetDynamicInfo` method on the **Dynamic Info Controller** reference. This will set the dynamic information that the NPC will use. In this example, we’ll initialize the Player’s health as a dynamic variable.
* **Updating the Dynamic Info**: Whenever you need to update the NPC with new information (such as a change in Player Health), call the `SetDynamicInfo` method on the Dynamic Info Controller.

### **Sample Scenario**

* At the start of the game, we set the Player’s health to 100 and send this information to the NPC as the initial value.
* Then, when the player takes damage (simulated here by pressing the "K" key), we reduce the Player’s health and update the **Dynamic Info** in real time so that the NPC remains aware of the Player's current health status.

<figure><img src="https://413558230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2Ftl8cFeZ7jzyVaqmGKrLm%2FUnity_DynamicInfo_ExampleCode.png?alt=media&#x26;token=a21a8f57-4fa0-4f47-aeaa-f46c45e8b35b" alt=""><figcaption></figcaption></figure>

### **Example Conversation**

Below, we provide a sample conversation showcasing how the NPC can react based on the dynamic health information of the Player. By dynamically updating the Player's health, NPCs can deliver responses that feel personalized and relevant to the current gameplay.

### **In summary**&#x20;

Add the **Dynamic Info Controller** to your NPC. Use `SetDynamicInfo` to initialize the dynamic variable at the start, and call `SetDynamicInfo` again whenever updates are needed.

This feature provides a powerful tool for creating NPC interactions that respond in real-time to the state of the game world, creating a more immersive experience for the player.

<figure><img src="https://413558230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FR3LWMw0ihvoUuM9YU56G%2FUnity_DynamicInfoConversation.png?alt=media&#x26;token=a0b095f1-de07-4ac8-8377-bfbcf8f8101b" alt=""><figcaption></figcaption></figure>
