Reminder - Keep Daily Backups

When working on a strategy game with a kit as big as the Complete Kit - always keep a working daily backup! Save yourself the trouble of rolling-back changes and losing work.

## After a player places a structure, can they move it?

Yes, buildings can be moved after they are placed. This allows for game players to redesign their map and village based on how they would like to customize their base. You can enable or disable this feature. All of the scripting is located in Scripts/Creators/BaseCreator.cs

## Grid coordinates system

Like many free to play strategy games - the player has an entire map that they can build their base on. In this case, each square corresponds to one grid coordinate. Moving structures moves then in this coordinate system. (You can choose whatever size map for your game, the demo map looks like the example below)

800
ο»Ώ

Map grid example. Click to view larger

## How are buildings moved?

There are three different control types included in the City Building Kit highest package. These control schemes are pre-built for developers to be able to build any sort of mobile, desktop, or console game. The following is a table of different functions:

UseFunctionDescription
All UsesMove()Moving pad arrows that you can tap to move structures by one grid coordinate.
PC GamesMouseMove()Tracks the mouse to have structures following the mouse location. Great for Windows/Mac games.
Mobile GamesTouchMove()Tracks touch to have structures following the user's touch. Great for mobile games.

There is a moving pad button located in the game scene UIAnchor - Bottom for each of the building types. This button activates the moving pad as seen in the below function

ο»Ώ

The buttons look like the following screenshot:

550
ο»Ώ

Moving pad controls appear. Click to view larger

Each of the moving pad buttons are relocated around the structure you have selected with the MovingPadOn() function in Scripts/Creators/BaseCreator.cs

ο»Ώ

## Touch and drag for mobile games

For game players to be able to touch and drag buildings we've included touch controls for mobile games in addition to the mouse tracking for desktop games and the moving pad controls for fine tuned movement.

The following script excerpt below shows the TouchMove() function in the Scripts/Creators/BaseCreator.cs script which tracks touch movements and translates them into grid coordinate movement.

ο»Ώ

## How the placement follows the mouse

For Windows and Mac games, we also use Raycasting to determine the mouse location which is used for relocating structures by tracking the mouse movement and attaching the structure to the mouse location. This makes it much easier for computer game users to interact with your game than using the moving pad alternative also included.

The following script excerpt below shows the MouseMove() function in the Scripts/Creators/BaseCreator.cs which tracks mouse movements and translates them into grid coordinate movement similar to how TouchMove() tracks touch.

ο»Ώ

## Alternative movement control - arrows

Other than touch and mouse controls, you also can use the moving pad arrow buttons.

461
ο»Ώ

Moving pad arrow that triggers MoveNW() function. Click to view larger

Tapping the top left arrow button in the example image above will trigger the MoveNW() function in Scripts/Creators/BaseCreator.cs each one of these moving buttons initiates one of the four cases for the BaseCreator.cs Move function.

ο»Ώ

The BaseCreator.cs Move function takes one of the four different ways to move in the grid coordinate structure (Northwest, Northeast, Southeast, and Southwest) and processes one of our different cases to step the building by one grid coordinate.

ο»Ώ

## Process to move a structure

First, select an object you would like to move.

636
ο»Ώ

Select object. Click to view larger

Then, tap the move button that appears in the bottom center of the screen.

550
ο»Ώ

Open move controls.

Moving pad arrows will appear around the structure. You can press the buttons or drag the building to relocate.

461
ο»Ώ

Tap an arrow to trigger moving process. Click to view larger

When finished, select the Checkmark button to save the new location.

550
ο»Ώ

Tap the checkmark to stop moving - or click on the building to drop.

## How collision errors are avoided

When you reselect a building for moving or when you are placing a structure - the grass colliders prevent accidental collision errors from occurring. Like placing a building over the other.

The following function triggers when you are moving a building, and you can see the last two lines when enable the GrassColliders:

ο»Ώ

A preview of how the grass colliders turn from green to red when you move over an existing structure.

553
ο»Ώ

Grass tiles detect collision errors. Click to view larger

When the colliders sense an existing building - the OK button to finish relocating the building cannot be selected. You'll see in the BaseCreator.cs OK() function below (triggered by the checkmark button) that we first check if there is an existing building by determining the Grass Collider's status.

ο»Ώ

## What happens after the structure is placed?

If the structure has already been created, then the BaseCreator.cs PlaceStructureGridInstant() function is triggered. Otherwise, the PlaceStructure() function is triggered which then sets up the timing and contstruction of the building (for new placements) save file example stores the grid coordinates

## Can I disable the ability to move buildings?

Yes. The simplest way to remove the ability for players to move buildings after they have placed them is to delete the move buttons in Unity from the Game scene UIAnchor - Bottom hierarchy elements. See the below images.

244
ο»Ώ

Where to find the move buttons in Game scene UIAnchor - Bottom

Also, in Scripts/Creators/BaseCreator.cs locate the ActivateMovingPad() function and uncomment the line MovingPadOn() as seen below:

ο»Ώ

ο»Ώ