Create a new character.
The following sections will show you how to create a new character and then add it to the shop. For this tutorial will be using the Ultimate Animated Character Pack.
We really recommend Quaternius assets as a source of CC0 licensed models. Download the model and import the FBX folder to the project.
Our goal is to create a character whose basic attack is a fire ball attack, and whose special attack is a meteorite fire ball attack (reusing the Wizard attacks included in the package).
Add the character component.
Drag the Witch model from "FBX/Witch.fbx" to the scene. Drag the Witch model to the scene.
Select the Witch in the scene and click on Add Component and attach the Game Character component to it.
The character must be in the CharacterAI layer (adding the Game Character component changes it to this layer by default). Add the GameCharacter component.
The following variables will need to be assigned in the Game Character inspector:
Sell For: Amount of currency at which the character will be sold. You should set an amount less than the purchase price, to avoid infinite money bugs. Set it to 1.
Traits: The traits that the character will have. To create new traits, see "Create a new trait". Drag or select from the list the Wizard trait.
Enemy Shooting Point: If the character receives a projectile, the transform inside the character where the projectile should go. Open the Witch object hierarchy and attach the Body transform.
Set the Original Stats. Each stat is briefly described below:
- Health: Life points possessed by the character. When it reaches 0, the character is defeated. Leave the default value.
- Damage: Physical damage to the character. Applies if some attack effect applies physical damage. Leave the default value.
- Magic Damage: Magic damage to the character. Applies if some attack effect applies magic damage. Leave the default value.
- Defense: Physical defense of the character. Reduces physical damage received. Leave the default value.
- Magic defense: Magic defense of the character. Reduces magic damage received. Leave the default value.
- Attack speed: Speed of the attack animation. Set it at 0.3, since the animation that will be used is quite short.
- Movement Speed: Movement speed of a character. Set it at 3.5.
- Range: Character's attack range. Make sure it is greater than 0. Set it at 5.
- Critical Probability: Probability of critical damage from basic attacks. Leave the default value.
- Critical Damage: Damage bonus from critical attacks. Leave the default value.
- Energy: Amount of energy needed to activate the special attack. Set it to 10.
- Energy Recovery Per Attack: Amount of energy generated by each basic attack. Set it to 10.
- Energy Recovery On Hit: Percentage of damage received that is transformed into energy. Leave the default value.
- Attack Effect (or Basic Attack): For this example, the witch will perform a fire ball attack. Drag or select the FireBallEffect from the list.
- Projectile Shooting Point: The point from which the projectile from basic attacks will be fired. Even if at first the character is not going to shoot projectiles, it is advisable to assign a position, since he can equip himself with an item that allows him to shoot them. This witch will shoot a ball from the hand. Open the Witch object hierarchy and find the Fist.R_end transform and attach it.
- Special Attack Effect: For this example, the witch will perform a range special attack. Drag or select the MeteoriteEffect from the list.
Create an empty GameObject inside the Witch object, rename it to UIPosition, and put it on top of his head, around (0,3,0). Attach this transform to UI Bar Position. GameCharacter variables at this point.
Create a new folder in the Project window. Drag the scene witch to the new folder to create a prefab. Make a Witch prefab by dragging it to the Project window.
Right click on the prefab. Select "Auto-Battle Framework/Create Shop Character". This will create an Animator Override Controller and a Character Shop Scriptable Object. Right click and select Create Shop Character.
Select the new created Shop Character (WitchShopItem.asset).
- Select a sprite for Item Image (we will use the witch-cap). This image will be displayed when available for purchase in the store.
- In the same way, select another sprite for Description Image (we will select the witch-cap again). This image will be displayed when the character's statistics panel is displayed.
- Add an Item Description if desired.
Select the images used in the shop and character description.
- We need to assign animations to the character. First, we will need to modify some import option of the animations. Select the original model of the Witch (FBX/Witch.fbx). Click on Animation. Then, in the clip list, select the animations described below and follow the steps for each of them.
- Death: Leave it at default.
- Idle: Activate the Loop Time option.
- Run: Activate the Loop Time option.
- Shoot_OneHanded: Activate the Loop Time option. Create an event around 0:20. In Object select GameCharacter, and in Function type Attack.
- SwordSlash: Activate the Loop Time option. Create an event around 0:50. In Object select GameCharacter, and in Function type SpecialAttack.
Import Settings of Shoot_OneHanded animation.
- Link the animations described in the previous step to the Animator Override Controller (WitchAOC). Make sure that the animations are the same as in the previous step.
- Attack: This animation will be used in the basic attack of the characters. Attach the Shoot_OneHanded animation.
- Death: This animation will play once when the character health reaches zero. Attach the Death animation.
- Idle_Attacking: This animation will play while the character is standing still without target. Attach the Idle animation.
- Run: This animation will play while the character is moving. Attach the Run animation.
- Shoot: Leave this animation unlinked. This animation will be executed only if the basic Attack Effect has the Double Animation option checked. It is used for attacks that require two animations, or you want to repeat them twice. For example, the Ranger that comes in the package has the animation of aiming the bow, and then shooting the arrow.
- Special Attack: This animation will be used in the special attack of the characters. Attach the SwordSlash animation.
- SpecialShoot: Leave this animation unlinked. his animation will be executed only if the special Attack Effect has the Double Animation option checked. It is used for attacks that require two animations, or you want to repeat them twice.
Linking animations in the Animator Override Controller.
Add the Shop Character to the Shop List. Open the "Auto-Battle" object hierarchy and select Shop Manager. Open the "Shop Level Manager/Shop Levels" list and select a list of stores. We will select the one called "Level 1-2-3". Add the witch's store item. Add the character to a shop level.
Remove the witch from the scene and press play. The witch should be purchasable in the store, and be a playable character. The witch can be purchased at the shop.