---
name: "BIS_fnc_spawnEnemy"
type: function
status: ok
groups: ["Object Manipulation"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/BIS_fnc_spawnEnemy
revid: 337523
updated: 2023-02-03T22:19:23Z
---

# BIS_fnc_spawnEnemy

*Function · Object Manipulation · Arma 3 v0.50 · introduced in Arma 2: Operation Arrowhead v1.50*

Locality: executed with **spawn**

## Description

Constantly spawns enemies around a player according to array of enemy classes. The units will try to hunt down the player.

## Syntax

```sqf
[aPlayer, target, side, classes, maxEnemies, delay, code] spawn BIS_fnc_spawnEnemy
```

**Parameters:**

- `aPlayer`: [Object](../topics/Object.md) - a unit that [is a player](../commands/isPlayer.md)
- `target`: [Object](../topics/Object.md) - reference object (enemies will be spawned on same direction in respect to the player)
- `side`: [Side](../topics/Side.md) - side of the spawned enemies
- `classes`: [Array](../topics/Array.md) of [String](../topics/String.md)s - list of enemy classes (units will form a group together)

  > [!IMPORTANT]
  > Classes must be of the defined *side*, otherwise they will attack each other.
- `maxEnemies`: [Number](../topics/Number.md) - (Optional, default 10) maximum number of enemies at once
- `delay`: [Number](../topics/Number.md) - (Optional, default 30) time between spawn waves
- `code`: [Code](../topics/Code.md) - (Optional, default {}) - code to execute on each unit (referenced by [_this](../topics/Magic_Variables.md#this))

**Returns:** [Nothing](../topics/Nothing.md)

## Examples

### Example 1

```sqf
[player, player, opfor, ["O_Soldier_F"]] spawn BIS_fnc_spawnEnemy;
```

## See also

[BIS_fnc_spawnGroup](../functions/BIS_fnc_spawnGroup.md) · [BIS_fnc_stalk](../functions/BIS_fnc_stalk.md)

<sub>Source: [BI Community Wiki — BIS fnc spawnEnemy](https://community.bistudio.com/wiki/BIS_fnc_spawnEnemy) (revision 337523).</sub>
