Object Placement

Guide on how to integrate placing buildable units with Unit System demo scripts.

Overview

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

1. Placement & Units

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

  • Create empty object and add ObjectPlacement component to it. Check all the tabs and configure it for your project.

  • Units may use their colliders by default if one is present, otherwise follow the guide to configure bounds for each units as well.

2. Player placement

Add EntityPlacementManager which will handle all the events for your and start object placement when a request is invoked. You can replace this script with custom event handling for the request.

Placements are requested by Production Module when production request is processed that requires building and therefore placement in the world.

if (player.TryGetModule(out ProductionModule module))
{
    module.OnStartPlacementRequest.AddListener(StartPlacement);
}

3. Disable Selection

While placing an object selection is still active and may interfere with placement by highlighting objects or even selecting them.

There are few ways to achieve this and here are two:

  • If you are using Unit Selection asset, then you may use the additional ActivePlacementSelectionToggler script which does only this, observe the placement events and enables/disables the UnitSelector.

Active Placement Selection Toggler with Placement Manager
  • For any integration you can always set up events of the EntityPlacementManager by yourself in code or directly in the scene.

Configured events in Scene

Last updated