> For the complete documentation index, see [llms.txt](https://infinitypbr.gitbook.io/magic-pig-games/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitypbr.gitbook.io/magic-pig-games/other/portrait-avatars/setup.md).

# Setup

{% hint style="success" %}
Don't forget to check out the Demo Scene, which has a working system ready to check out.
{% endhint %}

## 1. Create Layers

Each portrait must have its own layer. I suggest naming them "Portrait0", "Portrait1", "Portrait2" and so on.

Create new Layers for each of your portraits. Open the Layers drop down and click the "Edit Layers" option at the bottom of the list to create new layers.

<figure><img src="/files/6mWCTfdjzaWLkF62Gf1m" alt="" width="367"><figcaption></figcaption></figure>

{% hint style="warning" %}
If you plan on using the **Portraits Realtime Color** system, which is optional, you need to also create a layer for that. Call it "ColorSampler".
{% endhint %}

## 2. Bring in Portrait Avatars

The `Portraits/Prefabs` folder has a `Portrait Avatars Parent` object, which includes `PortraitAvatars` component on it.&#x20;

Bring this into your scene as a child of player object. Portrait Avatars instantiated during the game will be children of this object.

### Populate the Player Avatar Prefab

In the **Required** section of the `PortraitAvatars` component, you'll need to provide your Potrait Avatar prefab. This is avatar object which will be spawned into the scene. Check the demo scene to view the "Portrait Avatar - Demo" object. This object should contain a `Portrait` component.

{% hint style="success" %}
The "Portrait Avatar" object in the Prefabs folder can be duplicated and used as a starting point for your own portraits. Try getting the system working with a duplicated version of this before making a customized Avatar.
{% endhint %}

### Set the Available Layers

In the Available Layers drop down, select only the layers you created previously. These are the layers which will be assigned to each portrait. Note that your game can only have as many portraits as there are available layers.

### Set your Avatar Local Spawn Position

The Portrait Avatar Prefab you select will be instantiated at this position, local to the Portrait Avatars Parent object. If you are not using scene lighting to influence your 3D avatars, or if you aren't using 3D avatars, you may opt to choose a location that is very far away from the scene.

You can optionally set the Background Color and other values in the `PortraitsAvatar` component.

### Set Camera Options

<figure><img src="/files/Ae8HqgCVtbIZvabHFUsb" alt="" width="563"><figcaption></figcaption></figure>

Toggle on **Refresh Every Frame** to make the camera draw every frame — otherwise choose a specific frames per second. This optmizes the impact many portraits may have on your games FPS. Often keeping this a low value is not perceptible to players.

#### Background Camera

Optionally assign a background camera. When this is not assigned, the portrait cameras will act the way they are set up.

When this is assigned, each portrait will share the same background — often this is the opposite direction as the main camera, but can be any camera looking at anything.

You can set a refresh rate for this camera as well, often a higher rate than the portraits, since the motion will be more easily perceived by the players.

## 3. Bring in the Portraits UI

Bring the **Portraits UI** object, located in the `Prefabs` folder, into your scene as a child of your `Canvas`.

This is where your UI portraits will appear. The object is preset with UI components, though you may need to customize it to fit your project.

With **Portraits UI** selected in your Hierarchy, you'll see the `PortraitsPanel` component in the Inspector.

Populate the **UI Portrait** prefab with the prefab you will be using. By default, the UI Portrait prefab is selected. For now, you may wish to ensure everything instantiates properly before creating your own custom UI Portrait object.

## 4. Test it!

Bring the "Demo Buttons" prefab into your scene as a child of the Canvas. These are the buttons used in the Demo Scene, and they will allow you to test the set up, and confirm everything is working correctly.

Press play, and click the "Load Portrait" button in the top left. Your portrait should load!

Once that is working, you can create your own [**Portrait Avatar**](/magic-pig-games/other/portrait-avatars/setup/create-a-portrait-avatar.md) and [**UI Portrait**](/magic-pig-games/other/portrait-avatars/setup/create-a-ui-portrait.md), customized to fit your game, with your art work, and your unique logic.

{% content-ref url="/pages/uy9efunjVxBpfJDH8Kba" %}
[Create a Portrait Avatar](/magic-pig-games/other/portrait-avatars/setup/create-a-portrait-avatar.md)
{% endcontent-ref %}

{% content-ref url="/pages/5oqjUh6QrqzFbiIbAody" %}
[Create a UI Portrait](/magic-pig-games/other/portrait-avatars/setup/create-a-ui-portrait.md)
{% endcontent-ref %}
