Entity
So let's start our tutorial with creating an Unit. First, we need to arrange the folders:
- Create a Unit folder in a related Units directory. For the main repo the example is Content\Units\FactionName\Unit
- Create the proper subfolders (Animations, Materials, Meshes, Textures, UI).
- Assume we've just received all needed assets from our modelers and placed it by drag-n-drop to their respective folders.
Now we need to create a config.
Every entity - unit, building, lair, etc. needs a config. That is the place where we store all the data like health, damage, animations. It's easily accessible and configurable.
Basically it is just a Data Asset inherited from RTSEntityConfig or other RTS***Config class. Inherited means you have to pick this class when you create an asset/blueprint and you get the search field (second screenshot below). You can create a Data Asset by right-clicking in file explorer, and navigating to the Miscellaneous tab.
Type "unit" in the search bar.
Create a new asset and call it EC_[UnitName], so for example EC_Unit. It’s best to name it with a related prefix to avoid any confusion when we'll have a lot of files in the project.
During development some fields or sections in this config may be changed / moved / removed. As such, the screenshots below may be outdated at the time you read this.
We’re now ready to open our Data Asset and set up the unit. We’ll be going through all the (sub)sections that the asset is composed of:
- Construction
- Unit
- Attack
- Type
- Health
- Abilities
- UI
- Vision
- Experience
Construction
Group Size - How many units will be in the group (horde).
Resources Cost - The resources it costs to build the entity.
Command Points Cost - The command points required to build the entity.
Time Of Production - The time the unit production process takes, from when it starts. Only one unit per building can be produced at a time, the rest is placed into a queue.
Unit
Max Walk Speed - The maximum speed when walking/running.
Unit Skeletal Mesh - Place the unit’s Skeletal Mesh (SK)
Unit Static Mesh Collision - Place the Static Mesh with collision of the unit here. NOTE: currently we auto-generate the collision from the unit, and this field may be left empty. We are, however, still figuring out the most optimal way to handle this. Maybe after future bug testing we will need this field again.
Has Collision - Turns collision on/off. We are going for a realistic collision, so you should check this box.
Formation - Here we can set the formation of the horde. Right now we have:
- Line: Units will stand in a singular horizontal line. Pick this option for single units as well.
- Two Lines: Units will stand in a formation of two horizontal lines. This is our standard horde formation.
- Square: Units will stand in a square formation.
- Random Circle: Units will form in a messy, circle-shaped formation.
- Count: Units will form in a random, messy formation.
Retreating Distance - Currently this feature is broken, it’s supposed to set the Retreating Distance for auto attacks, just like for creeps. It doesn’t work at the moment.
Spawn Time - Other than you may expect, this is the time between a unit spawning and a unit becoming controllable by the player. It is to prevent spawn issues and/or play out spawn animations before a unit can be controlled.
Bannerman Config - Here you should set the EC for the related bannerman of the horde. For now, you may leave this empty. Further documentation about this will follow, the system isn’t fully prepared yet.
Animation - In this section we will be bringing the unit to life! We’ll be adding animations to make the unit functional. The files needed for this section should be available in the Animations folder of your unit.
Animations - there are multiple animation states as seen above. We’ll quickly go over them.
- Anim Idle: Animations that play when a unit is idle (standing still).
- Anim Run: Animations that play when a unit is moving.
- Anim Hit: Animations that play on hit. NOTE: Currently this state is currently not used and may be left empty.
- Anim Spawn: The spawn animation that plays when a unit is spawned in. Often this should be the most suitable animation from Run. Sometimes a unit has a custom spawn animation.
- Anim Die: The unit's death animation.
Change Idle Anim Rand Range - You can set up multiple animations for each state. For the Idle state, there is a random range in which the unit will play through its animations. Between X and Y seconds.
Blend Idle Anim Time - This blend time is used to blend between idle animation states. It’s meant to make the transitions smoother, for now we landed on the standard value of “1”.
Blend from Run Anim Time - This works similar to Blend Idle, but instead it does not blend between run animations, but rather between the run animation and switching to another state (like Idle). Unlike idle animations, run animations do not play between different animations during movement. This is to make movement look smoother. At the start of movement, the unit will pick one of the run animations, and stick to that.
Attack
Is Weapon Enabled - Whether this unit can attack. Uncheck for builders (porters).
Acquisition Radius - Radius in which the actor will automatically select and attack targets, in cm.
Chase Radius - Radius around the home location of the actor it won’t leave when automatically attacking targets, in cm. This is a function left from the RTS plugin, it currently is not functional.
Weapons - Properties of the default weapon (e.g. Arc for Legolas or archers). Here we will set weapons for this entity. More on that in Chapter 2 - WEAPONS.
Crushable Level - The crushable level of the entity. Currently we don’t have crush mechanics yet, but later on this value will determine the entity’s weakness against it.
Type
Entity Class - Point out what class of entity to spawn. We are working on making a list that describes all classes, for now we focus on the Unit class.
Is Neutral - This defines whether the entity will be “neutral”, like wild creeps (wargs and trolls on the map). Those will attack any player, they don’t pick sides. Do not check this for Entities intended to be used by players. (Neutral entities are part of team 66).
Health
Current Health - This is the health value that an entity spawns with. Almost in any case this should be equal to Maximum Health. Setting this value lower will mean the entity starts out hurt.
Maximum Health - The Maximum Health that an entity spawns with.
Current Armor - This defines what armor type the unit spawns with. Almost always this should be set to “Default”.
Default Armor - The default armor the entity spawns with, if Current Armor is set to Default. This defines the strengths and weaknesses of a unit. We don’t yet utilize it, but it is already functional and handled by the GAS system.
Heavy Armor - An upgraded armor state for the entity.
Abilities
Abilities - Array of abilities, made and handled through the GAS system. Make sure you do not remove elements from the map. It may crash the game!
UI
UIName - The name the entity will display in the UI.
UIDescription - The description the UI will display in the description box.
UILevel Requirement - The level requirement that will be displayed in the description box. Leave it at 0 if you do not need to display anything.
UICurrent Level - Should be set by CurrentLevel from the Experience category.
UIMax Level - Should be set by MaximumLevel from the Experience category.
UIHealth - Should be set by MaximumHealth from the Experience category.
UIDamage - The attack damage shown in the description box. As everything in UI, this is just visual!
UICost - Should be set by ResourcesCost from the Construction category.
UIShortcut - Visual representation for the hotkey of this entity. We currently do not have this functionality built. Leave it empty.
UICommand Points - Should be set by CommandPointsCost from the Construction category.
UIPurchase Level - Should be set by CurrentLevel from the Experience category.
UIIs Passive Ability - This is used for the description box for abilities. Units do not utilize it, leave it unchecked.
Portrait - The portrait that will be displayed in the bottom right Palantir Menu when the entity is selected.
Icon - The button icon that will be displayed for this entity.
Vision
Sight Radius - Radius in which the actor reveals areas covered by fog of war, in cm.
Experience
Current Experience - The experience the actor will spawn with. Almost always should be left at 0.
Current Level - The level the actor will spawn in. For units this almost always should be level 1.
Maximum Level - The maximum level the actor can get. For units the general BFME use case is level 5.
Experience Points for Each Level - The experience points required for the entity to level up to the next level, customized per level. Units gather this through the Bounty value of other actors. If setting this up, please notice that the Array starts at 0, and this means level 1. So, Array 0 is the experience required from level 1 to 2, Array 1 is the experience required from level 2 to 3, etc. This means the size should always be MaximumLevel -1.
Calculation: [0] = 5 exp is the required exp to reach level 1.
[1] = 10 exp is the required exp to reach level 2.
And so on.
Bounty - Experience given to units (other actors) when the actor dies.
Splash Radius - Distance between our dying actor and the furthest enemy getting the experience bounty.
Production Experience - Experience given to a production building when this actor is spawned. If we want to manually leveling up buildings, this should be left at 0.