ORK Framework Logo - RPG Editor for Unity
  • ORK 4 BETA
  • Features
  • Guide
    • Documentation
    • Tutorials
    • API
  • ORK 2
    • Tutorials
    • Plugins
    • 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
    • Hit & Miss
    • Critical Hits
    • Cast 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 Shortcut Slots
    • 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

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
  • ORK 4 Unity Quickstart Tutorials (3D)

14 Random Battles

In this tutorial we’ll add random battles to our game.

For now, we’ll only add them to the World scene (Assets/Scenes/) outside of town, so open it.

We’ll do two things:

  • set the battle scene variable
  • add random battle areas

Let’s get to it.

Battle Scene Variable #

Create a new empty object using the scene hierarchy’s context menu: Create Empty

Change the newly created object’s name to Set Battle Scene.

Variable Changer #

Add a Variable Changer component to the object using the component menu.

Variable changers are used to change variables without having to go through a schematic. They can e.g. be started automatically when loading the scene (which we’ll do), when entering a trigger or started by interacting with them.

Start Settings #

These settings define how the variable change is started – we’ll use the Ready start type (i.e. the machine will start when the level was loaded or the object was instantiated).

Components like the Variable Changer have quick-setup buttons available, the Autostart button will handle the setup for us.

Click on Autostart.

Variable Changes #

We’ll set the battleScene string variable to the scene name we want our battles to take place in.

Click on Add Variable.

  • Change Type
    Select: Variable
    We’ll directly change a variable instead of using a template.
  • Variable Key
    Set the value to: battleScene
  • Variable Origin
    Select: Global
  • Type
    Select: String
  • Operator
    Select: Set
  • String Value
    Set to: Forest Battle Arena
    You might notice that the string value fields automatically have all scene names available for selection (at least of the scenes added to the Unity build settings).

That’s it for the variable changer – now, each time we enter this scene, the battle scene used by the battle start schematic will automatically be set to the Forest Battle Arena scene.

Adding Random Battles #

Next, we’ll set up the Random Battle Area. This component will start battles while the player moves within it’s trigger.

We can create ready-to-use setups using the scene hierarchy’s context menu (ORK Framework > Battle > Random Battle Area (3D)) or the ORK toolbar (search for: Random Battle Area and use the 3D variant).

This’ll create a new object with a Random Battle Area component and a Box Collider 3D used as trigger.

Let’s adjust it to our needs.

Transform #

We’ll position it to cover the area outside the town gate.

  • Position
    Set to: X=188, Y=10, Z=86

Random Battle Area #

Now, let’s set up how often a random battle happens and which enemies can appear.

Random Battle Settings #

The Random Chance Settings in combination with the distance settings determine how often a battle happens. We’ll keep the default settings for battle chance and check interval.

  • Battle Chance
    Set to: 10
    There’s a 10% chance to start a battle when checked.
    Seems pretty high on it’s own.
  • Check Interval
    Set to: 0.5
    The time between performing 2 checks.
    I.e. there are 2 checks per second possible.

We can control how often a battle starts via the distance settings.

  • Minimum Move Distance
    Set to: 0.1
    The player needs to move at least 0.1 world units between checks.
  • Minimum Distance
    Set to: 10
    The next battle can start after the player has moved at least 10 world units.
  • Maximum Distance
    Set to: 25
    A battle will start without check if the player moved for 25 (or more) world units since the last battle.

Combatant Settings #

We’ll add multiple combatants/groups that will be used for random battles. Which one is used is determined by a chance check – each combatant/group we add defines the chance it has to occur.

The total of all chances should be 100 to have a full range of possible enemies. However, you can also define less or more – less would mean that if no enemy was found, no battle occurs. More, well, all exceeding the maximum chance (100 for all chance checks, can be changed  in the system settings) would never occur. You can see the total chance of all added combatants/groups at the top of the component’s settings.

Let’s get to it. We’ll begin with editing the already added Combatant 0.

  • Chance
    Set to: 60
  • Faction
    Select: Enemies
  • Use Group
    Disable
  • Combatant
    Select: Wasp

Copy the Combatant 0 setup and change the following settings.

  • Chance
    Set to: 40
  • Combatant
    Select: Snake

That sums up to 100 percent – 60% chance to fight a wasp, 40% chance to fight a snake.

Box Collider #

We’ll adjust the size of the box collider to cover the whole area outside the town gate.

  • Size
    Set to: X=70, Y=20, Z=130

More Random Battle #

Copy the Random Battle Area game object we just created, we’ll adjust it and use it for the upper part of the scene.

Transform #

We’ll position it to cover the upper area of the scene.

  • Position
    Set to: X=130, Y=10, Z=196

Random Battle Area > Combatant Settings #

We’ll change the chances of combatants to appear and also add the combatant group we’ve set up.

Combatant 0 #

  • Chance
    Set to: 30

Combatant 1 #

  • Chance
    Set to: 30

Combatant 2 #

Copy the Combatant 1 setup and change the following settings.

  • Chance
    Set to: 40
  • Use Group
    Enable
  • Combatant Group
    Select: Forest x2

That sums up to 100 percent – 30% chance to fight a wasp, 30% chance to fight a snake and 40% chance to fight a group of 2.

Box Collider #

We’ll adjust the size of the box collider to cover the whole area outside the town gate.

  • Size
    Set to: X=220, Y=20, Z=90

That’s it for the random battle setup.

Save the changes you’ve made in the scene.

Testing #

It’s finally time to fight! Hit play in the World scene and run outside town.

Everything seems to be working, we zoom into the battle and can attack the enemy (and get attacked or poisoned back).

Since our player doesn’t have any abilities (beside the base attack), the Ability battle menu option currently has nothing to display – also, there are no items in the player’s inventory, so the Item battle menu option is grayed out.

However, the actions appear to be happening at the same time. This is due to them not yet being animated, so they’re over in an instant.

Also, the camera is a bit far away, let’s change that.

Adjusting the Camera #

Open the Makinom editor and navigate to Controls > Camera Controls.

Camera Control 0 > Zoom Settings #

We’ll use zooming of our Top Down Border camera to define different distance and height limits for field and battle camera.

  • Use Zooming In
    Select: Battle

We don’t actually use any input to zoom, i.e. the player can’t zoom in or out, but we’ll set a limit for the camera.

Height Settings #

  • Max Height Battle
    Set to: 5

Distance Settings #

  • Max Distance Battle
    Set to: 10

Save Changes #

And that’s it!

Save the changes using the Save Settings button at the bottom of the editor.

Testing Again #

Hit play and start another battle outside of town.

That’s much better!

 

Next, we’ll start animating our actions.

Table of Contents
  • Battle Scene Variable
    • Variable Changer
      • Start Settings
      • Variable Changes
  • Adding Random Battles
    • Transform
    • Random Battle Area
      • Random Battle Settings
      • Combatant Settings
    • Box Collider
  • More Random Battle
    • Transform
    • Random Battle Area > Combatant Settings
      • Combatant 0
      • Combatant 1
      • Combatant 2
    • Box Collider
  • Testing
  • Adjusting the Camera
    • Camera Control 0 > Zoom Settings
      • Height Settings
      • Distance Settings
    • Save Changes
  • Testing Again
Sitemap
  • ORK 4 BETA
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • API
  • ORK 2 Hub
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get ORK
  • Contact
  • Blog
  • Makinom
  • gamingislove.com
Categories
  • News (73)
  • ORK 2 (137)
    • Tutorial (137)
      • Game tutorial (50)
      • Gameplay (32)
      • How-to (55)
  • Release (156)
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!