Hatred
Not enough ratings
[Hatred] Mod Guide #4 | How to spawn enemies on your map
By DC_vipeout
This one will help you understand how is it our spawning systems work, including cars and survival specific logic. After following this guide you will be able to handle setting the type, number and placing of enemies on the map.
   
Award
Favorite
Favorited
Unfavorite
Introduction
Another guide for you guys, again I'm just the messenger ;) The original author is DC_Gaijin and the original post is here.[forums.hatredgame.com]

<< Previous Guide
Setting up the navigation mesh
Navigation mesh (the area inside which pawns can move) is generated inside "Nav Mesh Bounds Volume"

You can find this actor in Modes Window=>Volumes

Place it on map and scale it to area you need. You can press "P" button to see nav mesh bounds, or turn it's preview on, by getting into "Show" tab=> Navigation, notice it doesn't build inside the static meshes)

Now when you have proper nav mesh you can dit it in few ways using NavModifierVolume.
First is cutting pieces of nav mesh off,
and second, changing av mesh "cost" (so AI's will prefer walking through some parts of it if it's cheap or try to avoid some places if it's expensive)
you can find this actor it in the same place as Nav Mesh Bounds Volume(Modes=>Volumes)

After you put it on map,and scale it to proper size, the property you're looking for is AreaClass in Default Section of this actor details (F4)

You can notice, navigation mesh inside this volumes will change depend onwhich class you choose.
Spawning AI's from HatredAISpawnArena
This actor is used to fill map mostly with NPC pawns (although it might be used to spawn so strayin' cops), it prevents spawning too many pawns on the map and balance pawns count as player moves from one SpawnArena to another,so there're only pawns close to the player on map and spawn another ones as player moves to different part of level (to different AiSpawnArena).

To use it, first thing you need to do is placing many "HatredSpawnPoint"s on your map, you can find them in Modes=>All Classes and type "HatredSpawnPoint". Notice it has an arrow showing the direction spawned pawn will face.

Also, you can place additional actors like Wander Point's (actors betweens which Pawns will work before they notice player) and Safe Spots (actors to which NPC will run when they notice player. You can find them in the same section in Modes window.

When you got that done, press "F4" button having HatredSpawnPoint selected to see it's properties.

Now you have to set this thing up,the section we need to setup is SpawnPoint as you can see in the image it has multiple variables to available those are:
Available Pawns array: list of available presets of pawns from which Arena will choose which character will be spawned (it's important when setting up the AiArena later)
Wander Points Set: Set of points between which Ai will walk until it notices player.Once you got them on map, you can pick them from the list (just click little down arrow to see list of available) or pick it using pick tool on it's right. (pawns will be staying in one place when it's empty)
Safe Spots Set: set of places to which unarmed NPC can run away trying to hide when they notice player.Pawns will run to random places when it's empty.
Randomize Wander Points: should pawn walk between this wander points in order you put them or pick random each time
Can be Used Once: Should AiArena use this spawn point once
Spawn Anim/Spawn Montage: plays naimation on Pawn (like sirring in the chair, checking his phone etc.)
Loop Anim: loops spawn anim until pawns notices player (unless it is paused)
Can be Killed: Can this pawn be killed when balancing total pawn alive count (better be true)
No Collision Fail: allows spawning Pawns InsideCollision (like when they have spawnAnim "sitting" in the chair)
Pause on Spawn: Should pawn spawned from this spawn point be working on it's AI or be disabled
Is Junkie/Is Hipster: those are achivement variables (kill n hipsters etc.) won't be usefull for you.
Emotional State on Spawn: should spawned pawn be already running away or wandering around


Now when you got this one SpawnPoint done, just repeat it as many times you need, on map in each place you want pawns to be available to spawn.

Having this done, you can finally setup the arena, find "HatredAISpawnArena" actor in Modes window and place it on your level. Resize it to the size of area you want it to cover, having in mind that once Player got into it, only pawns from it's spawnPoints will be spawned and there's a limit of them too (as we tested over120 pawns causes massive framedrop) so it's better to have many areas and balance pawns more often, but arena must be big enought for player not to see spawns. Arenas can also overlap each other, in that case, only area which's center is closer to the player will be working.

Properties Arena has:

Check Full Arenas: describes wheter or not this area should be checked for toggling when it's pawns
are already spawned (recommeded to be on FALSE)
Max Pawns on Map: total count of available alive pawns on map, important thing is, all areas should have same count here.
Spawn Time Interval: time interval between each spawn, Personally I recommend to set it to about 0.05 so pawns will spawn very fast, but not in the same frame.
Spawning Pawns Classes: that array describes which pawn sets should be used in spawing (that should be the same as in spawn points).
Number Pawns Per Class: that describes how many pawns per class listed above should be spawned.
Available Spawn Points: list of spawnPoints available for this arena, so when player enters it, arena will try to spawn pawns in this places.
Min distance to Player: minimal distance from player to spawnpoint to make it available to spawn (that prevents spawns close to the player)
Randomize Pawn Classes: That means whether or not arena should pick spawns in order you put them in Spawning PawnsClasses or randomize it. I recommend setting it to TRUE
Use Spawn Point Once: flag describing whether spawnpoint should be disabled after one use or should it be available for many spawns.
Force Spawning: when true Arena will start spawning immidietly after level starts, no metter of MinDistance to Player.
Force Spawn Expire time: timer disabling flag above when it's done
Force Only for Player Inside: that on TRUE means Arena will not check minDistance to player when picking spawnpoint.
Minimal Distance to kill: that's distance from player to pawn above which it can be killed when players gets from one arena to another

That Pawns fields below, lists which blueprints should be used for each class setten on top(so for name CIVILIAN MALE ou use CIVILIAN_01, CIVILIAN _02 etc)


The algorithm goes like that: player get's into area, it checks if max pawns on Map are lesser than pawns alive count, then it picks spawnpoint from distance longer than minimal if it's class is the same as classes descibed in Spawnning Pawns Classes, waits interval, then tries to spawn another one.
Spawning AIs from spawnpoint (used for custom actions because it's deterministic and always works the same)
Sometimes you might want to spawn a full squad of AIs of the same kind, that's how our Hatred Spawn AIFormation node works. So suppose you want to make a simple script which spawns 4 cops when player reaches some point on your map. You need a trigger, CheckOverlap makro which checks whether player is in a car or not, it works and a Hatred Spawn AIFormation node which looks like that:


as you can see it has multiple inputs such as

Formation Class: that's a class of formation which indicates mostly their target object distance which is a distance from some object you set, pawns will try to keep close to. I usually use a default HatredAiFormation and set a Target Object Radius manually
PawnClass: class of pawns to spawn
Num Members: how many pawns to spawn
Extraction Point: point close to which pawns will be spawned
Locator: location of Formation actor (doesn't really matter what you connect to that)

Last three are optional (is ttarget object is null, squad will move freely throught the map)
Target Object: location close to which squad will try stay to, protect it
Target Object Radius: maximal distance from target point in which pawns will move
Target Expire Time: how long squad will keep the distance to target point. -1 means pernament
Spawning one AI from location
Easiest thing ever, you just need to connect a Locator actor (a simple Note will do) at which pawn will be spawned, and choose a Pawn Class.

Spawning Cars and giving them a route to ride
So suppose you want to spawn a car and set his destination to go.
All you need to do is Spawn AiFromClass node with right Pawn class (remember that you need a car with some pawns in it, otherwise it would not ride), a location and rotation of spawn (easy to get from some sprite actor like note) and a Car Route Move To node with points on route.


Target: a car which you want to move
Route: an array of actors which keeps locations of points on car's route
Loop route: should car loop the points (like if you want a civilian car driving around a city)
In Rolling stop: should car stop at the last point or slow down earlier and roll to the last point
Maximum Speed: not really km/h, usually we use about 13
In additional offset to stop at final destination: a distance at which car will start stopping.
Survival Wave Spawner
This methode works only on survival game mode, so it's useless in campaing but if you're makin a survival map, that will do the job for you ;)

First thing you need to do is placing on map special survival spaning actors (bp_survivalSpawnpoint) which keeps locations of 10 spawns. depends on your map, on how many characters would you want to spawn at once but I advice to place so many spawners that their total locations available will be at least as big the max number of pawns you gonna spawn.


When you got that done, you need to place SurvivalPositionCheckers and assign Spawnpoints to them in their defaults.

SurvivalPositionChecker is a volume which controlls where player is and then decides which spawnpoints should be used so if player is in one PositionChecker spawnpoints assigned to it will be used (but those should not be inside it, 'cos you don't want player to see spawning.


As soon as you've got all map covered with those position checkers and they've got assigned spawnpoints, you can add a SurvivalWaveHandlerActor, assign to them all your position checkers (in it's defaults) and setup the actual waves in NewWaves array.
Spawning many Ais from AI Director
6. Spawning many Ais from AI Director

AiDirector is a main spawned on most of levels.
Basically, it counts player's kills and spawn waves of predefined enemies and some thresholds.
We use it to spawn walking patrols and cars driving to players location. You can find it's blueprint in Content\Blueprints\Game. Put in on map.

Firstly, walking cops.
You'll need to place many bp_policeSpawnpoints (from now on,I'm going to refer to it as SP) on map, place them in spots, law enforcemens should spawn, from one SP up to 8 pawns can be spawned.

As soon as you place SPs on map you need to assign them to AiDirector, you propably will have plenty of them, but there's easier way than assigning one at the time.
- Select AiDirector
- press Lock icon on top of it's details window
- now your AiDirector is like permanently selected, no matter what you press, this details will refere to this actor (you can open multiple Details windows)
- select all SPs on map (select one, and pres ctrl+a)
- now, having those selected, back to AiDirector's details, find "SpawnPoints on Map Array, and pres button on right of it, the on with two arrows pointing left


More intresting things in this details are
- Is On - is AiDirector Toggled on and counting kills, easy.
- Car Bringing Volumes - array to assign to volumes used for car patrols (I'll explain later on)
- Count Civilians - should AiDirector count kills of civilians (you need to define thresholds of kills, after each number of kills, AiDirector will spawn wave, so it needs to know what kind of kills you need)
- Count All - should count all types of AIs (cops, soldiers, civilians, swat etc)
- Count Armed - should count all with guns (but spawned with guns, if civilian pick up the weapon, it would not count as armed)
- Count Only Soldiers - count soldiers
- Delay Before Spawn - if true it will wait from 1 to 5s after threshold to spawn wave - be carefull with it, it might ♥♥♥♥ things up if your thresholds are close to each other (like 2,4,8 kills) and player can got into two at the same time (like grenade killing 5pawns), in those cases better turn it off
- Distance From Player To Spawnpoint - minimal distance at which AiDirector will look for SP, used 'cos we don't want pawns to spawn in players frustrum
- No Delay but Play sound - if true, when threshold achived, it won't wait but there will be police alert

Other variables are used in blueprint script and shouldn't be visible..

Now,You need to setup thresholds of kills, and pawns in waves.
Go to level blueprint and place AiDirectors reference. You'll neen to use SetupAiDirector function on it. Best time to se it BeginPlay, as if it's On it will count kills but has no thresholds for waves.

There are few inputs, and all of them need something connected, you can use your variable, or drag input, press MakeArray , and fill created literal array

- Kills Thresholds - this array tells AiDirector at which amount of kills the wave should be spawned, each row is a number of kills. So basically array [3,5,8] will start spawning after three, five and eight kills
- Pawns Count For Threshold - describes how many pawns should be spawned for each wave (walking pawns, cars array is below) i
- Pawns To Spawn On Map - type of pawns per wave, each row is assignet to wave
- Randomize Pawns - when true it will always pick Randoms AiTypes from Pawns To Spawn On Map Array, when spawning wave
- Cars - array of cars per wave - you can pick many cars per wave as this structure have array in array
- Max Cops Alive - Condition to check when spawning wave, if limit is topped, wave would not spawn

Remember, indexes in those arrays are correlated (index 0 of thresholds indicates will use index zero PawnsCount etc.)
If you've done this setup, ai director should spawn walking waves from now on


Now withCars, thing is a bit more complicated. Cars need their own Spawnpoints (CarSpawn), RoutePoints (CarRoutePoint) and CarBringingVolume

First place CarBringing Volumes on map. Those actors check where is player, find closest Car route and give it to AiDirector so it can spawn Car. Place many of those actors on our map, so they cover each place you want cars come to.

Now, you should place CarSpawns in this volume, each of them can be used in many routes, but each rout can be used only once. Fill CarSpawnsArray in each CarBringingVolume.

Another thing are Route points, place many of them, on the route from each spawn point to Car Destination (last routePoint in Route array is car's destination, you can select this actor and Select checkbox IsEndPoint, you'll see car-sized box so you know ~wher car will be at the end of the route

example of one route and CarSpawn below

Now back to Car bringing volume,you need to setup Routes Structure, each route index correlates with Spawnpoint, so Route 0 will start from CarSpawn0..
Add RoutePoints in correct order for each SpawnPoint

Car bringing volume also has a Var - Debug Start, use it to check if your routes are correct (just set it True, and press simulate, or play - cars will spawn)

Can Be Used Once - if true this car bringing volume will spawn only one wave

Now, repeat of many, many car bringing volumes on your level ;)


That's my AiDirector setup for 3 waves:

Also, here's testmap with one CarBringingVolume setup
1 Comments
DC_vipeout  [author] 20 Sep, 2020 @ 11:01pm 
No, we do not plan to add any more tutorials for Hatred.