Adding Soldiers and Tanks to your maps
Adding AI Soldiers and Tanks in Levels
This guide explains how to add Tanks and AI soldiers in your levels.
Tanks and AI soldiers are controlled by the player by giving orders to Units. You MUST have Tanks or AI soldiers be a member of a Unit to be able to order them to move to locations or to order them to attack targets.
AI solders are spawned into the game using a CharacterSpawneractor. There is a CharacterSpawnerUSAactor (used to spawn U.S. soldiers) and a CharacterSpawnerGermanyactor (used to spawn German soldiers) that you can place in your levels.
Each of these can be set up to spawn a soldier automatically, or they can be configured to wait for a trigger before spawning a soldier. See the 'gbxCharacterSpawner'properties of the CharacterSpawnerUSAor CharacterSpawnerGermanyactor for the spawn settings.
Tanks can be spawned into the game by using a TankSpawneractor. The type of tank (US or German) can be selected in the 'TankSpawner'properties of the TankSpawneractor using the 'TankType'setting. Tanks can also be configured to automatically spawn when the level is loaded or configured to wait for a trigger before spawning the tank.
You can place a player drivable tank in the level by setting the 'bPlayerDrivable'setting to 'True' (NOTE: currently there are no plans to make a tank drivable by the player in the single player game, but if you need to test out whether a tank can be driven properly across level terrain, you can temporarily make the tank drivable by the player, spawn the tank into the game, then move to the left or right side of the tank and USE it to drive it yourself).
Now that you have CharacterSpawnerUSA, CharacterSpawnerGermanyand TankSpawneractors in your level, you need to create some Units for them to join.
Add a 'Unit' actor to your level. Edit the properties of the Unit actor. Set the 'bUnitID'to a UNIQUE number (each unit should have a unique number assigned to it). In order for the player to be able to command multiple units, the player should be in a "super unit" by themselves, and you need a unit for each of the groups that the player will control.
For example, if I had a Unit of 3 AI soldiers, and a Unit with a tank, I would need 3 Unit actors in that level (one for the player, one for the 3 AI soldiers, and one for the tank). The name for each unit is set in the 'Tag' setting of the 'Events' group in the Unit properties.
For the player's Unit, set the Tag name to something like PlayerUnit. For the AI soldier Unit, set the Tag name to something like SoldiersUSA, and for the tank Unit, set the Tag name to something like TankUSA.
Making units player controllable
Now that you have 3 Unit actors in the world, you need to make then have the proper relationship to each other. The PlayerUnit will own both of the other 2 Units. This is done by editing the properties of the SoldierUSAand TankUSAunits. In the 'Unit' group, set the SuperUnitName to the name of the player's Unit (in this case, SuperUnitName=PlayerUnit).
Each Unit will have a leader. The leader of the Player's Unit will be the player. So for the PlayerUnit, you need to set 'bMakePlayerLeader'to True.
For the other 2 Units, you should set 'bMakePlayerLeader'to False. On the Player's Unit, you will also need to set 'bPullPlayerIn' to True (to force the player to join that unit). On the other 2 Units, you should set 'bPullPlayerIn' to False (to keep the player from being pulled into those units).
Now you need to assign the AI soldiers and the Tanks to their specific Units. You do this by editing the properties of the CharacterSpawnerUSA, CharacterSpawnerGermany, or TankSpawneractors.
For the CharacterSpawnerUSAand CharacterSpawnerGermanyactors, look in the 'CharPawn' group at the 'UnitToJoin' setting. This should match the name of the Unit that you want them to join (i.e. it should be the same as the Tag name of the unit). In this case, the AI soldiers will have the UnitToJoin set to SoldierUSA. The tank's UnitToJoin setting is in the 'TankSpawner' group. Set this to the Tag name of the unit it should join (in this case UnitToJoinshould be set to TankUSA).
Now you have the units set with their proper relationship to the player's Unit, you have the AI soldiers and Tanks assigned to the unit they should join. The last thing you need to do is to pick a leader for each Unit.
Select ONE of the AI soldiers in each Unit and look at the 'bLeader' setting in the 'CharPawn'group of the properties. The soldier that you want to be the leader of the Unit should have 'bLeader' set to 'True'. All other soldiers in that Unit should have 'bLeader' set to 'False'. When the leader of a unit gets killed, one of the other soldiers in that unit will automatically become leader of the unit.
Pathnodes for tanks
In order to lead your soldiers and tanks around in the level, you must have a valid path network for them to use to navigate. You do this by placing PathNodeactors in your level. Place them at all of the places where you want AI guys to be able to move to while the game is running. Place them near cover locations so that AI guys will know where to move for cover when a battle begins.
Tanks require special actions by level designers to work properly with PathNodes. Tanks will follow the same paths that other AI soldiers will follow, but the level designer MUST indicate which PathNodeactors the tanks should use while navigating.
Edit the properties of a PathNodeactor and look at the NavigationPointgroup. You will see a 'bTanksCanUse' setting that defaults to False. For the specific PathNodesthat you want tanks to be able to use (and **ONLY** for those specific PathNodes), you should set 'bTanksCanUse' to True. You **DO NOT** want to set 'bTanksCanUse' to True for all PathNodes. You only want to set bTanksCanUse to True for the specific paths that you want tanks to follow.
In essence, you are forcing the tanks to take **VERY** specific routes between points in the level. For example, if you level had a road down the middle and various wooded areas on the side of the road. You would select the PathNodeactors that lead down the road and set 'bTanksCanUse' on these PathNodes to True (thus forcing the tank to stay on the road and not try to navigate between all the trees in the wooded area). For tanks to follow a valid path, you **MUST** set 'bTanksCanUse' to 'True' for all the path nodes along that path. (See the next section for how to view paths in a level).
You can view which paths will be taken by tanks by right-clicking on the window title bar of any of the View windows in UnrealEd(for example, "Top", "Front", "Side" or the 3D view). Select "View" and then "Show Tank Paths" to display the paths that can be taken by tanks.
You will have to rebuild the paths in your level after adding, removing, or moving PathNodeactors. Do this by clicking on the "Build Paths" button in the UnrealEd top toolbar (it looks like 5 little spots connected with some lines). You can also use the "Build Changed Paths" button (it looks like the Build Paths button except 2 of the dots are red) to rebuild the paths between PathNodesthat have changed since the last time you build the paths in your level.
After building the paths, you should be able to use the "View->Show Paths" and "View->Show Tank Paths" to display paths that can be taken by AI soldiers or Tanks in your level.