Unit System
  • WELCOME
    • πŸ‘‹Hello
    • πŸ—ΊοΈRoadmap
    • ⛑️Support & Community
    • πŸŽ“Version - Changelog
  • Getting Started
    • πŸ”ŒImport Package
    • βš™οΈConfiguration
    • πŸ” Database
    • πŸͺŸManager Window
    • Creating a new Scene
      • Player Camera
      • Set up Player
      • Set up Player UI
      • Set up the Game World
    • Create Units
      • Resource (Crystal)
      • Research (Crystal age)
      • Resource node (Crystal Node)
      • Resource collector (Crystal)
      • Combat unit (Mage)
      • Production unit (Mage Tower)
      • Faction (Purple Cubes)
  • How it works
    • Overview
    • Modules
      • Resource
      • Production
      • Population
      • Garrison
      • Collection
  • Integration
    • Unit Selection
    • Unit Formation
    • Object Placement
Powered by GitBook
On this page
  • Overview
  • 1. Placement & Units
  • 2. Sync with Selection
  • 3. Add to Player Interactions
  1. Integration

Unit Formation

Guide on how to integrate formation behaviour with Unit System demo scripts

PreviousUnit SelectionNextObject Placement

Last updated 15 days ago

Overview

This page is for guiding you through the process of basic integration for package. Refer to the if you need more information.

1. Placement & Units

If you do not have Unit Formation package present, then follow it's guide for import and scene setup:

  • Add FormationPlacement prefab in scene, configure it and its input

  • You can skip FormationUnit component, but each unit still must have a script which implements IFormationUnit. You can do this by:

    • Updating your unit prefabs from using NavMeshMovement to FormationNavMeshMovement instead. It only extends functionality for the formation by implementing IFormationUnit interface. This way any update that happens to the formation position will cancel current active task that the units may have.

    • Or if you are not using the provided movement scripts, make sure your movement script also implements IFormationUnit to receive a command to move unit to the new position in formation.

2. Sync with Selection

In this step we need to sync selected units with formation package, so that formation placement may be used with all the selected units.

  • Add SelectedUnitsFormation component to your player, this will delegate any selection changes on EntitySelectionManager to the FormationPlacement component. This component also requires the Player reference, to make sure there are no unowned entities in the formation unit list.

Now you should already be able to use Formation Placement actions with the selected units.

3. Add to Player Interactions

This step adds formation capability to normal interactions for the selected units. When you are using provided demo scripts for interactions (TargetedUnitInteractions component) it already positions units in formation when there is no entity to interact with in that position. We now want to use the Unit Formation package to achieve this.

If you are not using provided interaction components, you can skip this step.

  • Add FormationPlacement prefab from the Unit Formation package to your scene and configure it for your project.

  • If you followed the Set up Player, find the for the Player Interactions object of your Player in the scene, and replace the TargetedUnitInteractions component on it with TargetedFormationUnitInteractions.

    • This can be done by removing current component and replacing it with a new one, and then make sure all the references in scene are now pointing to the new component.

    • Another way to do it is to enable Debug view in Inspector and replace the script reference to the new class. And that's it.

Unit Formation
Formation Guide
FormationNavMeshMovement component
Enter Debug view and replace class type