# Using your own character Squadcraft does not replace your character, your weapons or your health. It plugs into what you have. ## The player Enemies treat a pawn as hostile when: 1. its class is in the **Hostile Classes** list of the controller's Awareness component, or 2. it (or its controller) has a team through the Generic Team Agent interface, and the team is different, or 3. it is controlled by a player and has no team at all (**Treat Players As Hostile** on the Awareness component, on by default). Most projects need nothing: the player has no team, so rule 3 makes it an enemy. If your players do use teams, give the enemies a different **Team Number** on their controller. ## Stealth To make the player harder to see (in shadow, crouched in grass, camouflaged), implement the **SQ Stealth Target Interface** on it and return its visibility from Get Squadcraft Visibility: 1 in plain view, 0.25 in deep shadow, 0 unseen. Sight fills the awareness meter that much slower; at 0.25 a guard 10 m away takes about four times as long to spot it. Noise and hits are not affected. How you measure light is yours: a light sensor, volumes, a crouch. ## Health and damage Squadcraft attacks deal **standard engine damage** (Apply Point Damage for shots and melee, Apply Radial Damage for grenades). Anything that reacts to Event AnyDamage, Event PointDamage or Take Damage gets it, so your health system works unchanged. To tell Squadcraft when a character is dead (so the AI stops shooting at the body, and a dead enemy stops thinking), either: - implement the **SQ Combat Target Interface** on the character and return your own "is alive" in **Is Combat Target Alive**, or - use `SQHealthComponent`, the small replicated health that comes with the plugin. A Squadcraft AI checks its own body through the same test four times a second, and stops (senses, tree, cover, squad, abilities) when it dies. Call **Notify Pawn Died** on the controller to make it immediate. Using the Gameplay Ability System for damage? Set a **Damage Effect Class** on the abilities: it is applied to the victim's ability system with the damage as the set by caller magnitude `Squadcraft.SetByCaller.Damage`. Turn off **Apply Engine Damage** if you only want the effect. ## The enemy's body Any Character with a skeletal mesh works; the AI only needs the capsule and the Character Movement component. A pawn on Mover or your own movement works too, through the SQ Pawn Movement Interface: see [Player squads, spawners and doors](6-player-squads-spawners-doors.html). It crouches behind low cover, so allow crouching in your animation (the controller turns on Can Crouch for you). Shots start at a socket named **Muzzle** on any mesh of the enemy (the weapon, usually). Without it they start at the eyes. Change the socket name on the fire ability if yours is called something else. The ability system: if your enemy already has one (through the Ability System Interface or a component), Squadcraft uses it. If not, the controller adds one when it possesses the pawn and gives it the combat abilities. ## The Game Animation Sample character Epic's Game Animation Sample character (`SandboxCharacter_CMC`, motion matching and all) fights on Squadcraft with two steps, checked on 5.8: 1. In a Blueprint child of it (or the character itself): **AI Controller Class** = `SQAIController`, **Auto Possess AI** = Placed in World or Spawned. 2. Add the **SQ Movement Variables** component. Its defaults are this character's: it sets `CharacterInputState`'s Wants To Walk on patrol, Wants To Strafe and Wants To Aim while the AI is Alert, and Wants To Crouch behind low cover. Why the component: that character picks its speed every frame from those variables, so a Max Walk Speed set from outside is gone the next frame. Any Blueprint character that works the same way (ALS, your own) takes the same component with its own variable names; leave State Variable empty when the bools sit on the character itself. It has no weapon, so shots start at its eyes: add a socket called Muzzle on a weapon mesh for a muzzle and tracer in the right place. ## Animations Two things drive your Animation Blueprint: one-shot animations for what the AI does or suffers, and state tags for the poses that last. ### The animation set Create a data asset of class **SQ Animation Set** and give it to the controller's **Animation Set** (or tag the pawn `Animations:/Game/Path/To/YourSet` to give one enemy placed in a level its own). It lists every action, each with an animation, a slot, a play rate and blend times: | Action | When | |---|---| | Fire, Suppress, Blind Fire | each burst starts | | Sniper Aim | the sniper's telegraphed aim, before the shot | | Reload, Throw Grenade, Melee Strike, Vault | the ability starts (an ability's own Montage wins over the set) | | Hit Front, Hit Back, Hit Left, Hit Right | it takes damage, from the side the attacker is on. At most one every 0.4 s | | Death | it dies | | Flinch | the moment it becomes suppressed | | Enter Cover, Leave Cover | it reaches its cover spot, or leaves it | | Peek Left, Peek Right, Peek Over | it leans out of high cover, or rises over low cover, to fire | | Open Door, Body Found, Boss Phase, Evade | as named; Evade is running from a grenade | | Signal | a hand signal with the callouts that move the squad: contact, flanking, moving, falling back | | Suspicious, Alerted, Calmed | something caught its eye; into a fight (not when a hit is what alerted it: the hit reaction shows instead); back to calm after a search | An action left empty plays nothing and sends nothing over the network. While an ability plays its own montage (reload, melee, grenade, vault with a Montage set) the set's actions wait, except Death: the ability system replicates that montage and clients would start it again over anything else. Death keeps its last frame (**Hold Last Frame**, on for Death in a new set) so a body without ragdoll stays down; for a montage, turn off Enable Auto Blend Out in the montage itself. A montage plays in its own slots; any other animation sequence plays in the entry's **Slot**. A new set starts with Fire, Suppress, Blind Fire, Sniper Aim, Reload, Throw Grenade, Open Door and Signal in `UpperBody` (the legs keep walking) and the rest in `DefaultSlot`, so your Anim Blueprint needs those two slots, or change them to yours. The server picks the action and the pawn's **SQ Animation** component plays it on every client. The controller adds the component when the pawn has none; add it to your pawn Blueprint yourself to bind **On Animation Action** (a sound, an effect), or turn off **Play On Mesh** to play it your own way. The set has to be an asset: one made at runtime does not replicate. Call **Play Animation Action** on the controller to play one from your own logic. A set given only through the `Animations:` pawn tag is loaded by path, so nothing references it and a packaged game leaves it out. Put it in **Additional Asset Directories to Cook** (Project Settings > Packaging), or set it on the controller Blueprint instead, which references it. ### State tags Replicated loose tags on the pawn's ability system, so clients see them too. Read them in the Anim Blueprint with Has Matching Gameplay Tag: | Tag | On while | |---|---| | `Squadcraft.State.Alert` | it is in a fight | | `Squadcraft.State.Aiming` | alert with a target to point at, and not reloading | | `Squadcraft.State.InCover` | at its cover spot (within 1 m), with `CoverLow` or `CoverHigh` for its height | | `Squadcraft.State.Peeking` | out of its cover to fire | | `Squadcraft.State.Suppressed` | the suppression meter is over the threshold | | `Squadcraft.State.Pinned` | suppressed behind its cover: it won't lean out | | `Squadcraft.State.Telegraphing` | an attack wind-up runs | | `Squadcraft.State.Reloading`, `Squadcraft.State.Vaulting` | as named | `Squadcraft.State.Firing` is on while a burst runs, on the server only. They update four times a second and on every change of activity, and all go off when it dies. Crouching comes through the Character's Is Crouched, as usual. ### Sounds Create an **SQ Sound Set** and give it to the controller's **Sound Set** (or tag the pawn `Sounds:/Game/Path/To/YourSet`, which is how one squad gets several voices). It has: - **Actions**: a sound for any of the animation set's actions (reload, a hit from each side as pain, death, flinch, alerted, vault...); - **Callouts**: the voice line for each callout tag (`GameplayCue.Squadcraft.Callout.Contact`, `.Flanking`, `.Grenade`, `.Reloading`, `.ManDown`, `.FallingBack`, `.Suppressing`, `.Moving`, `.BodyFound`); - **Shot**: every shot of the fire, suppress, blind fire and sniper abilities, at the muzzle; - **Grenade Explosion**: its grenades going off. Each is a list of takes: one is picked at random and never the same twice running, at a random pitch between Pitch Min and Max, with its own volume, attenuation and **Min Interval** (a burst of hits makes one grunt, not five). Anything left empty plays nothing and sends nothing. They play on every client through the pawn's SQ Animation component, attached to the pawn; its **On Sound Played** event gives the sound and, for a voice line, the callout tag, to show it as a subtitle. The demo uses `/Squadcraft/Demo/DA_SQDemoSounds`: CC0 recordings of a rifle shot, a reload, a grenade, grunts of pain and death and a swing (sources in ThirdPartyNotices.txt). It has no voice lines: the demo writes the callouts over the soldiers' heads. ### Gameplay cues `GameplayCue.Squadcraft.Shot` (Location is the muzzle, Normal the direction to the impact and RawMagnitude the distance to it, for flash and tracer), `GameplayCue.Squadcraft.Telegraph`, and the callouts `GameplayCue.Squadcraft.Callout.*` for voice lines (see [Profiles and difficulty](5-profiles-and-difficulty.html)). ### The demo The demo soldiers use `/Squadcraft/Demo/DA_SQDemoAnimations`: the Game Animation Sample's shove reactions for hits, its vault, a step back for evading and a wave for hand signals. Their animation has no Anim Blueprint, so the soldier binds On Animation Action and plays each one itself. The Game Animation Sample character takes the same montages through its own Anim Blueprint: checked on 5.8 with the shove montage on a hit. ## The player's weapons Two calls make your weapons and grenades count for the AI, both in the SQ Combat Library: - **Report Shot**, once per shot: enemies the bullet passes close to are suppressed. - **Report Danger**, where your grenade lands: enemies in the blast run out of it. And, as for any AI Perception setup, **Report Noise Event** for gunfire, so they hear it. Next: [Squads and tactics](3-squads-and-tactics.html).