ORK 4 RPG Framework Logo
  • ORK 4 GUIDE
    • Documentation
    • Tutorials
    • Extensions
    • API
  • ORK 3 GUIDE
    • Documentation
    • Tutorials
    • API
  • Support
  • Forum
  • Get ORK

ORK 4 Documentation

  • Getting Started
    • Welcome
    • First Steps (Unity)
  • Features
    • The Status System
    • Schematics
    • Schematic Nodes
    • Dialogue Importer
    • Variables
    • Selected Data
  • Components
    • Battle Components
    • Combatant Components
    • Control Components
    • Cursor Prefab Components
    • Game Starters
    • Interactable Components
    • Move AI Components
    • Scene Setup Components
  • Editor
    • The ORK 4 Editor
    • Sections & Sub-Sections
    • Node Editor
    • Schematic Editor
    • Asset Sources
    • Unity Overlay Toolbar
  • Section: System
    • System Settings
    • Languages
    • Organizer Types
    • Game States & Conditions
    • General Condition Templates
    • Object Pools
    • Prefab Savers
    • Scene Connections
  • Section: Controls
    • Game Controls
    • Interaction Settings
    • Player Controls
    • Camera Controls
    • Input Keys
    • Control Maps
    • Camera Positions
    • Battle Camera
  • Section: Gameplay
    • Game Settings
    • Formulas
    • Difficulties
    • Shortcut Slots & Settings
    • Custom Settings & Global Custom Settings
    • Global Machines
    • Machine Templates
  • Section: Status
    • Status Values
    • Status Effects
    • Attack Modifiers
    • Defence Modifiers
    • Abilities & Ability Developments
    • Status Developments
    • Research Trees
    • Damage Types
    • Status Bonuses & Templates
    • Status Condition Templates
  • Section: Inventory
    • Inventory Settings
    • Inventory Containers
    • Currencies
    • Items
    • AI Rulesets
    • Crafting Recipes
    • Equipment Slots & Slot Set Templates
    • Equipment & Available Equipment Templates
    • Shops
    • Loot
  • Section: Combatants
    • Combatants
    • Combatant Groups
    • Class Slots
    • Classes
    • Factions & Faction Benefits
    • Animations
    • Move AIs
    • Formations
    • Action Combos
  • Section: Battles
    • Battle Systems
    • Turn Based Battles
    • Active Time Battles
    • Real Time Battles
    • Phase Battles
    • Battle Spots
    • Battle AIs
    • Battle Actions Settings
    • Special Commands Settings
    • Target Settings
    • Target Selection Templates
    • Battle Range Templates
    • Battle Grid Settings
    • Battle Grid Highlights
    • Battle Grid Cell Types
    • Battle Grid Formations
  • Section: Content
    • Content Types
    • Music
    • Sound Templates
    • Areas
    • Teleports
    • Quests & Quest Tasks
    • Logs & Log Texts
    • Object Contents
  • Section: UI
    • UI Settings
    • UI Layers
    • UI Layouts
    • UI Boxes
    • HUDs
    • Notifications
    • Cursor Settings
  • Section: Menus
    • Start Menu
    • Save Game Settings
    • Option Categories
    • Menu Screens
    • Menu Requirements
    • Battle Menus
    • Loot Dialogues
    • Item Collection
    • Combatant Selections
    • Quantity Selections
    • Shop Layouts
  • Section: Texts
    • Text Settings
    • Formatting Settings
    • Flying Texts
    • Use Cost Display
    • Status Preview Display
    • Bonus Display
    • Status Change Display
    • Console Settings & Console Types
    • Text Codes
  • Sections: Editor
    • Editor Settings
    • Backups
    • Variables
    • Plugins
  • Scripting
    • Access Handler
    • Custom Nodes
    • Custom Save Data
    • Custom Component Save Data

ORK 4 Tutorials

  • ORK 4 Unity Quickstart Tutorials (3D)
    • ORK 4 Unity Quickstart 3D
    • 01 Initial ORK Setup
    • 02 Player Setup
    • 03 Music & Scenes
    • 04 UI System Setup
    • 05 UI Boxes
    • 06 Flying Texts
    • 07 Status Values
    • 08 Status Effects
    • 09 First Abilities
    • 10 Fighter Setup
    • 11 First Enemies & Battle AI
    • 12 Battle System Setup
    • 13 Animating Battle Start and End
    • 14 Random Battles
    • 15 Animating Actions
    • 16 Player Battle HUD
    • 17 Elemental Attacks
    • 18 Animating More Actions
    • 19 Inventory & Loot
    • 20 Equipment
    • 21 Loot, Start Equipment & Viewers
    • 22 Magic Abilities
    • 23 Caster Setup
    • 24 More Enemies
    • 25 Start Menu & Save Games
    • 26 Menu Screens
    • 27 Interactions
    • 28 Item Collectors
    • Quickstart Extended
  • Battle Tutorials
    • Active Time Battles
    • Phase Battles
    • Real TT 01 Real Time Battles & Tab Targeting
    • Real TT 02 Control Map, Use Ranges & Battle Area
    • Real TT 03 Camera Control, Battle AI & Reuse Time
    • Real TT 04 Damage Detection, Action Animation & Player HUD
    • Real TT 05 Switch Player & Final Adjustments
    • Hit & Miss
    • Critical Hits
    • Cast Time
    • Reuse Time
    • Grid 01: Battle Grid Setup
    • Grid 02: Highlights
    • Grid 03: Cell Types
    • Grid 04: Move Command
    • Grid 05: Scene Grid Setup
    • Grid 06: Battle Ready
    • Grid 07 Use & Affect Ranges
    • Grid 08: Better Camera Control
  • Gameplay Tutorials
    • Multiple Interaction Controllers
    • Player Group Spawn & Follow
    • Spawn Hunting Enemies
    • Gamepad Controls (Unity Input System)
    • Combined Inputs
    • Control Map for Keyboard (Shortcuts)
    • Control Map for Gamepad (Shortcuts)
    • Quests 01: Menu Screen
    • Quests 02: Hunting
    • Quests 03: Collect Potion Materials
    • Quests 04: Collect Equipment Materials
    • Quests 05: Quest Mark HUDs
    • Crafting 01: Menu Screen
    • Crafting 02: Materials & Recipes
    • Crafting 03: Getting Materials
    • Crafting 04: Proficiency & Critical Outcome
    • Shop
    • Inventory Containers
  • Schematics Tutorials
    • UI Animation Schematics
    • Flying Text Animation Schematics
    • HUD Conditional Schematics
  • UI Tutorials
    • Unity UI: Initial Setup
    • Unity UI: Status Value UI Setup
    • Unity UI: Status Effect UI Setup
    • Unity UI: Shortcut UI Setup
    • Unity UI: Dragging Notification
    • Unity UI: Interaction HUD
    • Unity UI: Shortcut HUD
    • Unity UI: Turn Order HUD
    • Unity UI: Cast Time HUD
    • Unity UI: Quest HUD
    • Unity UI: Tooltip HUD
    • Unity UI: Move Range HUD
    • Menus 01 UI Box Setup
    • Menus 02 Template HUDs
    • Menus 03 Menu Setup
    • Menus 04 Main Menu
    • Menus 05 Inventory
    • Menus 06 Equipment
    • Menus 07 Ability
    • Menus 08 Group
    • Menus 09 Quest
    • Menus 10 Crafting
  • Module 01: Status System
    • Introduction to Modular Tutorials
    • M01.1: Status Values
      • Introduction to Status Values
      • Health
      • Mana
      • Barrier
      • Base Experience
      • Class Experience
      • Spendable Experience
      • Normal Stats
    • M01.2: Modifiers
      • Introduction to Modifiers
      • Element
      • Attack Type
      • Size
      • Race
    • M01.3: Status Effects
      • Introduction to Status Effects
      • Buffs
      • Debuffs
      • Poison
      • Regeneration
      • Blind
      • Stun
      • Sleep
      • Silence
      • Enchants
      • Charm
      • Doom
      • Reflect
  • Module 02: Actions
    • Introduction to Actions
    • M02.1: Formulas
      • Introduction to Formulas
      • Physical Damage Formula
      • Magical Damage Formula
      • Hit Chance
      • Critical Chance
    • M02.2: Abilities
      • Introduction to Abilities
      • Base Attack
      • Elemental Magic Spells
      • Steal Ability
      • Drain
      • Healing Spell
      • Cure
      • Buff Abilities
      • Debuff Abilities

ORK 4 Extensions

  • Plugins
    • Save Game Compression Plugin
  • Schematic Nodes
    • Footstepper Nodes (Unity)
  • Scripts
    • A* Pathfinding Movement Component (Unity)
    • PolyNav 2D Movement Component (Unity)
    • Cinemachine Camera Control Type (Unity)
    • Rewired Input Key (Unity)
    • Unity Legacy Input Key (Unity)
    • Core GameKit Wrapper (Unity)
    • Pool Boss Wrapper (Unity)
View Categories
  • Guide
  • ORK 4
  • ORK 4 Tutorials
  • Gameplay Tutorials

Spawn Hunting Enemies

0:00 / 12:06
  • View as Markdown Open this page as plain Markdown (opens in a new tab)
  • Open in ChatGPT Ask questions about this page (opens in a new tab)
  • Open in Claude Ask questions about this page (opens in a new tab)
  • Open in Google AI Studio Ask questions about this page (Google account required) (opens in a new tab)

In this tutorial we’ll spawn enemy combatants in the scene.

The enemies will hunt the player using a move AI and automatically start a battle when coming close to the player.

We’ll set up:

  • schematic for idle behaviour at waypoints
  • move AI
  • combatant spawners at defined positions
  • area combatant spawners

This tutorial is based on the ORK 4 Unity Quickstart 3D tutorials, but can be used in any project.

Idle Schematic #

Move AIs can use schematics to define an idle behaviour when a combatant reaches a waypoint. Once the schematic is finished, the combatant will continue to the next waypoint.

We’ll set up a simple schematic that randomly waits for a time betwee two waypoints.

Open the schematic editor.

Wait #

Add Node > Base > Wait

We’ll wait for a random time between 1 and 5 seconds.

  • Random
    Enable
  • Time
    Select: Value > Value
    Set the value to: 1
  • Time 2
    Select: Value > Value
    Set the value to: 5

And that’s it for the schematic. Click on Save Schematic to save it, e.g. as RandomPatrolWait.

Hunting Move AI #

Move AIs are used to let combatants determine targets for movement, while the actual movement is handled by the combatant’s movement component setup.

Open the ORK editor, navigate to Combatants > Move AIs and either add a new move AI or change the Default move AI if you haven’t used it yet.

Base Settings #

  • Name
    Set to: Hunt

Move Range #

We’ll limit the range a combatant will move in – this is measured from the combatant’s spawn position.

  • Use Move Range
    Enable
  • Range
    Select: Value > Value
    Set the value to: 10

Auto Stop #

  • Use Auto Stop
    Disable
    We’ll not use this, but it can be useful, depending on the movement component you’re using for your combatants.

Speed Settings #

These settings define at which speed a combatant moves for different modes. The default settings are enough, we’ll just change the Waypoint Speed.

  • Speed Type (Waypoint Speed)
    Select: Walk
    This’ll use the combatant’s walk speed.
    The Speed setting is only used as a fallback if no walk speed could be determined.

Waypoint Settings #

These settings handle waypoint movement, either for randomly selected positions or fixed waypoints defined by a Combatant Spawner or Add Combatant component used to add the combatant to the scene.

  • No Combatant Radius
    Enable
  • Enable Random Patrol
    Enable
    We’ll randomly patrol within a defined area.
  • Patrol Radius
    Set to: 10

Idle Settings #

  • Enable Idle
    Enable

Click on Add Idle Schematic.

  • Schematic Asset
    Select: RandomPatrolWait

Enemy Detection #

These settings handle how the combatant will detect enemies. We’ll detect enemies on sight within 10 world units and within an angle of 90 degrees of the forward direction of the combatant

  • Use Enemy Detection
    Enable
  • Timeout
    Set to: 0.5
  • Range
    Select: Value > Value
    Set the value to: 10

Click on Add Detection.

  • Type
    Select: Sight
  • Use Raycast
    Enable
    We’ll do a line of sight check.
  • Layer Mask
    Select the Default layer (only).
    To first unselect all other layers, select the Nothing layer, followed by the Default layer.
  • Use Child (User)
    Select: Path
    We’ll define the path to a child object.
  • Find Child (User)
    Set to: Head
  • Use Child (Target)
    Select: Path
  • Find Child (Target)
    Set to: Head
  • Angle
    Set to: 90

Target Position Check #

  • Lost Position Check
    Enable
    When the detected target leaves the detection range, the combatant will keep following it until the lost interval runs out.
    Otherwise the combatant will move to the last known position.

The target checks define how often the target’s new position is forwarded to the movement component – depending on the used component (we’ll use NavMesh) this can be more or less performance heavy. We’ll add different checks do increase the update interval when the target gets closer.

  • Interval
    Set to: 0
  • Minimum Distance
    Set to: 0

Click on Add Target Check.

  • Interval
    Set to: 0.2
  • Minimum Distance
    Set to: 2

Click on Add Target Check.

  • Interval
    Set to: 0.5
  • Minimum Distance
    Set to: 5

Click on Add Target Check.

  • Interval
    Set to: 1
  • Minimum Distance
    Set to: 10

Hunting Settings #

We don’t have to do more than just enable hunting.

  • Use Hunting
    Enable

Combatants General Settings #

Now we’ll set up the default movement component (which will handle the actual movement) and default move AI used by our combatants.

The combatant directly controlled by the player will never use a move AI – in case you spawn other members of the player group, they can use a move AI, e.g. to follow the player around.

Navigate to Combatants > Combatants and select the General Settings.

Battle Settings > Auto Start Battles > Start on Range #

We’ll change how close an enemy has to come to the player to start a battle.

  • Auto Start Battles
    Enable
  • Range
    Select: Value > Value
    Set the value to: 1.5

AI Settings > Move AI #

  • Use Move AI
    Enable
  • Move AI
    Select: Hunt

Animations & Movement > Movement Component #

The scenes are set up for NavMesh, and that’s what we’re using to move the combatants.

  • Component Type
    Select: Nav Mesh Agent
  • Add Component
    Enable

Save Changes #

And that’s it for the editor setup – don’t forget to save your changes by clicking on Save Settings at the bottom of the editor.

Radius for Combatants #

The move AI’s range checks (and other range checks) can also take the radius of a combatant into account. You can set up a radius by adding a Radius component to the combatant prefabs – and that’s what we’ll do.

The setup is pretty simple, just add a Radius component to all combatant prefabs found in Assets/Tutorial Assets/Prefabs/Combatants/Enemies/ and Assets/Tutorial Assets/Prefabs/Combatants/Player/.

The Radius component will automatically set the radius based on the prefab’s collider (Character Controller in case of our combatant prefabs) when added.

You can select multipe prefabs and add the combatant to all of them at once.

Spawning at Positions #

We’ll change the World scene from using Random Battle Area components to spawned combatants.

Combatants are spawned using Combatant Spawner components, you can learn more about them in this documentation.

Disabling Random Battles #

Open the World scene and disable the 2 Random Battle Area objects – you can easily identify them by either their name (and having the component attached) or their gizmo icon:

We’ll place a few combatant spawners in the area near the town entrance to spawn at the position of the spawners..

1st Spawner #

The first combatant spawner will be placed directly at the entrance to the town – and it’ll be a one-time-only battle, i.e. using the spawner’s Scene ID. Like item collectors, Battle and Combatant Spawner components use a Scene ID to mark if a battle was finished and shouldn’t occur again.

Add a combatant spawner either using the scene hierarchy context menu (ORK Framework > Combatant > Combatant Spawner) or the ORK toolbar (search for: Combatant Spawner). The variant withouth 2D or 3D added will be set up as an auto spawner, i.e. it’ll spawn when the level was loaded.

  • Use Scene ID
    Enable
    The scene ID will automatically get the next known valid number (should be 0 right now).

Start Settings #

Our spawner should be set up to use the start type Ready.

We’ll keep it that way. If you spawner isn’t set up like this, use the Autostart button to set it to the Ready start type.

Combatant Settings #

A combatant is already added for us, let’s set it up.

  • Faction
    Select: Enemies
  • Use Group
    Disable
  • Combatant
    Select: Wasp
  • Quantity
    Set to: 1

Spawn Settings #

Since we’re using NavMesh, it’s best to enable this setting:

  • Use NavMesh Positions
    Enable
    This’ll prevent any warnings NavMesh warnings from occuring when spawning combatants.

2nd Spawner #

Add a new combatant spawner at a different position. This time we’ll not use a scene ID, instead allow the combatant to respawn after time.

However, since we’re not fighting in the same scene as the combatant spawner, we need to keep track of the spawner’s combatants and respawn times, or a new combatant would spawn when we return from the battle.

  • Use Scene ID
    Disable
  • Remember Combatants
    Enable
    This’ll keep track of the combatants status and respawn times between scenes.
    The Spawner ID is used to store the information and was randomly assigned upon creation of the spawner.

Combatant Settings #

  • Spawn Random
    Enable
    We’ll add multiple combatants to the spawner and randomly spawn one of them.
  • Respawn Random
    Enable

    Respawning will use a different, random combatant.

Change the already added combatant.

  • Faction
    Select: Enemies
  • Use Group
    Disable
  • Combatant
    Select: Wasp
  • Quantity
    Set to: 1
  • Respawn
    Enable
  • Respawn Time
    Set to: 30
    Enemies will respawn after 30 seconds.
    Feel free to change the time to your liking.

Copy Combatant 0 and change the following settings.

  • Combatant
    Select: Snake

Spawn Settings #

  • Use NavMesh Positions
    Enable

3rd Spawner #

Copy the second spawner and place it somewhere else.

We can keep the setup as it is, but we need to get a new Spawner ID.

Click on Get New Spawner ID.

4th Spawner #

Copy the third spawner and place it somewhere else.

Click on Get New Spawner ID.

I’ve placed the 4 spawners like this:

Spawning in an Area #

When a combatant spawner has an area attached, spawning happens within the area instead of fixed spots.

Unity: A collider with Is Trigger enabled defines the area of the object.

1st Area Spawner #

We’ll add an area spawner in the upper right part of the scene, use the scene hierarchy context menu (ORK Framework > Combatant > Combatant Spawner (3D)) or ORK toolbar (search for: Combatant Spawner (3D)).

Adjust the position of the object and size of the collider to look like this:

  • Use Scene ID
    Disable
  • Remember Combatants
    Enable

Combatant Settings #

Change the already added combatant.

  • Faction
    Select: Enemies
  • Use Group
    Enable
  • Combatant Group
    Select: Forest x2
  • Quantity
    Set to: 10
  • Respawn
    Enable
  • Respawn Time
    Set to: 30

Spawn Settings #

We want to spawn the combatants within the area defined by the object.

  • Use NavMesh Positions
    Enable
  • Spawn Type
    Select: Collider
  • Layers
    Select only the Default layer.
    We’ll only use the default layer for raycasting positions to spawn the combatants.

2nd Area Spawner #

Copy the 1st area spawner and change it’s position, rotation and collider size to look like this:

We can keep the same setup – we just need to get a new Spawner ID.

Click on Get New Spawner ID.

Save Scene #

And that’s it for the scene’s setup.

Don’t forget to save the changes.

Testing #

Hit play and run out of town.

https://orkframework.com/wp-content/uploads/ork4_tutorials_gameplay__spawning_hunting_enemies_demo.mp4

The enemies spawn and start hunting the player of sight – all’s working as it should.

Custom Move Range (Optional) #

You can enhance the move AI’s use with different components added to your scenes. Learn more about available components in this documentation.

We’ll use a Move AI Range component to define a custom move range using an area in the scene. Combatant Spawner and Add Combatant components can use them to set the move range for their combatants.

Unity: Uses colliders with Is Trigger enabled as area.

Move AI Range #

Let’s add one to the scene to allow the enemies in the upper part of the scene to freely move around in a large area.

Add a move range using the scene hierarchy context menu (ORK Framework > Move AI > Move AI Range (3D)) or the ORK toolbar (search for: Move AI Range 3D).

Place it and increase the collider size to roughly cover the entire upper area, I’ve placed mine like this:

Transform #

  • Position
    Set to: X=131, Y=8, Z=190

Box Collider #

  • Size
    Set to: X=200, Y=20, Z=80

Move AI Range #

The Move AI Range component has options to define which functionality of the move AI it’ll limit, we’ll use both:

  • Limit Random Patrol
    Enable
    This’ll set the range for random patrol, allowing the enemies to freely run around in the entire area instead of the 10 world units set in the move AI’s settings.
  • Limit Move Range
    Enable
    This’ll set the range for all movement, i.e. the enemy can hunt, flee, etc. within the entire area instead of the 10 world units set in the move AI’s settings.

Updating Combatant Spawners #

Select the 1st area spawner, we need to set the move AI range for the added combatants.

Combatant Settings > Combatant 0 #

  • Move AI Range
    Select the Move AI Range component we’ve added.

Repeat this for the 2nd area spawner.

Table of Contents
  • Idle Schematic
    • Wait
  • Hunting Move AI
    • Base Settings
      • Move Range
      • Auto Stop
      • Speed Settings
    • Waypoint Settings
      • Idle Settings
    • Enemy Detection
      • Target Position Check
    • Hunting Settings
  • Combatants General Settings
    • Battle Settings > Auto Start Battles > Start on Range
    • AI Settings > Move AI
    • Animations & Movement > Movement Component
    • Save Changes
  • Radius for Combatants
  • Spawning at Positions
    • Disabling Random Battles
    • 1st Spawner
      • Start Settings
      • Combatant Settings
      • Spawn Settings
      • Combatant Settings
      • Spawn Settings
    • 3rd Spawner
    • 4th Spawner
  • Spawning in an Area
    • 1st Area Spawner
      • Combatant Settings
      • Spawn Settings
    • 2nd Area Spawner
    • Save Scene
  • Testing
  • Custom Move Range (Optional)
    • Move AI Range
      • Transform
      • Box Collider
      • Move AI Range
    • Updating Combatant Spawners
      • Combatant Settings > Combatant 0
Sitemap
  • Showcase
  • ORK 4 Guide
    • Documentation
    • Tutorials
    • Extensions
    • API
  • ORK 3 Guide
    • Documentation
    • Tutorials
    • API
  • ORK 2 Hub
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get ORK
  • Contact
  • Blog
  • Makinom
  • gamingislove.com
Categories
  • News (75)
  • ORK 2 (137)
    • Tutorial (137)
      • Game tutorial (50)
      • Gameplay (32)
      • How-to (55)
  • Release (158)
Search

© 2015 Gaming is Love e.U.

Disclosure: This site may contain affiliate links, which means I may receive a commission if you click a link and purchase something that I have recommended. While clicking these links won’t cost you any money, they will help me fund my development projects while recommending great assets!