Menu Character
The demo shows a character next to the inventory in the main menu. There are a few ways this could be set up from scratch. Here are two options:
Option 1: Make a UI Character by Duplicating your character
This character visually shows the items equipped, without having any game play logic. This can easily be set up using an Equipper script.
The steps are as follows:
- Duplicate your character and remove all the scripts from it leaving only the animator. Make sure the Animator is not set to Root Motion.
- Add an Equipper script (Avoid using the VisualCharacterEquipper or the CharacterEquipper script as those are demo only scripts)
- Create an Item Slot Set. Right-click in the project view -> Create -> Ultimate Inventory System -> Inventory -> Item Slot Set
- Set the Item Slot Set in the in the Equipper
- As the UI character does not usuallly use item you may ignore the Usable Item Prefab Attribute Name. Simply set the Prefab Attribute Name, which should point to the prefab that you will wish to see when the character equips a weapon.
- Make sure to set The Inventory to monitor and set the Item Collection to point to the equipped items.
- Finally set the Item Object Slots by selecting each slot in the list. you may choose whether the object is skinned or not. If not you may choose the parent transform for the item.
At that point the UI character should be set, The next steps are to display it in the UI.
- Create a Render Texture. Right-click the project view -> Create -> Render Texture. Assign it a reasonable size (The size you plan to use in the UI).
- In the UI add a Raw Image game object and assign it your Render Texture. This is the image that will show your character.
- Add a new Camera inside your UI and make it look at your UI Character you created in the first steps. Make sure the Camera and the character is very far from the game world (underneath it if possible) so that it cannot be seen. Another option is to simply put it on another Layer and Cull it from the main camera.
- Set the camera background to solid Color, Clear Flags to Solid Color and the background alpha to 0. This will render the character with a transparent background.
- The camera should have its Target Texture field set with the Render Texture.
With these steps you should now have a UI character displaying the equipped items.
Most of the times you character will need to animate holding the weapons, There is unfortunately no way to do this easily. You must create a custom Equipper to do this and smartly play the equip animations. A more versatile solution is planned for the future.
Option 2: Place a camera in front of your player character
- Create a Render Texture. Right-click the project view -> Create -> Render Texture. Assign it a reasonable size (The size you plan to use in the UI).
- In the UI add a Raw Image game object and assign it your Render Texture. This is the image that will show your character.
- Create a Camera inside the player Character game object in your scene and rotate it such that it looks at the character
- Assign the Render Texture to the camera Target Texture Field
- Set the camera background to solid Color, Clear Flags to Solid Color and the background alpha to 0. This will render the character with a transparent background.
- Tweak the Culling Mask, and Clipping planes to show the character and its weapons
This solution is quite a lot simpler than option 1 but it also comes with a few quirks. For example this won’t work for first person view characters. Also since the character being rendered is in the scene it will react to anything in the world, you won’t be able to pause the game while the menu is up or play custom animations for the UI character