Insane Systems RTS Starter Kit Guide
Insane Systems RTS Starter Kit Guide
Note
We’re moving documentation to the new platform, you can find it here:
insanesystems.net/APIDocumentation/RtsStarterKit
If the site doesn’t open, a VPN service can help. Also this documentation will be
available locally in the next asset versions.
Old documentation in the Google Docs is still available, but we do not plan to update it
anymore.
Content
1. Introduction
2. Information
I. Quick Start
II. Project preparation
III. Unit modules description
IV. Unit data description
V. Production categories description
VI. Faction description
VII. AI Description
VIII. Electricity mechanic
IX. Dependencies
X. Known Issues
3. Settings and customization
I. How to change unit settings?
II. How to setup a new unit?
III. How to setup a new building?
IV. Automatic unit/building setup
V. How to set up house color parts of units?
VI. How to setup units with turrets?
VII. Melee-ranged attack type
VIII. How to setup wheels for vehicles?
IX. Shell - create custom rockets and bullets
X. How to setup infantry units
XI. Unit abilities, how to use
XII. How to add or edit Production Category?
XIII. How to add and setup a new map?
XIV. How to add a new faction (race)?
XV. Fog of War
XVI. Map settings checker
XVII. Setting up single player (campaign) map
XVIII. How to customize game UI?
XIX. Best settings for NavMesh
XX. Sound Library and Sound Editor
XXI. Triggers
XXII. Win Conditions
4. Programming
I. How to create my own module?
II. How to use features of RTS Starter Kit modules in my own module?
III. Using of RTS Starter Kit events
IV. Creating new unit Abilities
V. Our code conventions
VI. Online API Documentation
5. Roadmap
6. Contacts
7. Credits
Introduction
RTS Starter Kit asset is designed to simplify development of RTS game. This asset
is primarily designed to create military RTS, which have vehicles, bullets, etc., but
you can use it in other game styles. It contains a lot of components, which you
need to know to simplify your work with the asset and this guide will help you to
do it. But do not worry, all these components are simple to understand.
Guide contains three main partitions:
- Information - information about asset objects, resources and components.
- Settings and customization - information about asset settings, which help
you to customize examples for your RTS.
- Programming - this partition contains information, which will help you to
implement your own functionality.
You can open this guide online in Google Docs by using this link:
https://docs.google.com/document/d/1jM-
qJoNewQ2HnpzaUbwVG6VSX94sXPAGT5YRK15mUDA/edit?usp=sharing
In Google Docs you can quickly navigate between partitions by using Document
Structure on the left side of the window.
Information
Quick Start
Best way to understand how it all works - check the Lobby and Example scenes. It
contains all used components which are shown in a simple RTS Game prototype.
Have a detailed look at it and if you have questions - go ahead and read the next
sections of this guide. In this partition below you’ll read some basic principles
descriptions first, after it you can go to Settings and Customization partition with
more details.
Project preparation
Firstly, to run the prototype properly, check that Lobby and Example scenes
added to Build Settings. It should be done automatically by code, but if not, add it
manually.
Next, you can check that the asset automatically added new layers: 9 - Unit, 10 -
Terrain, 11 - Fog of War, 12 - Resource field. First is used to indicate ground
object on maps, second – for all game buildings and units, third - indicates fog of
war, final is for resource fields.
These fields should be filled automatically, if it is not done, please, add these
layers manually.
AI Description
This asset contains bots (computer enemies). Currently their AI is simple, but
flexible to an extent. Now AI Bots can create buildings, buy units and send them
to attack enemies. Current AI Settings looks like this:
Think time is time between different AI Actions. Increase it to decrease bots
actions per minute.
Building Priority is a list of buildings allowed to build for bots. Bots will create
them in order of list.
Units Categories contains a list of ProductionCategory objects, which can be built
by bots. For example, if you add default Factory Building to Building Priority and
want bots to build units from this factory, you should add to Units Categories its
production category. In template this category is Vehicles. Removed in 1.7.0, use
Units To Build instead.
Available from version 1.7.0
Units To Build is the most important thing here. You can setup, which units and in
which order will be built by AI. You also can set time before they will be built and
time after. More info you can get by pointing by cursor to its elements, there
appears a detailed Tooltip.
Electricity mechanic
Electricity is used in a lot of classic military RTS, so we decided that it will be good,
if thing like this will be implemented in our asset.
This means that some buildings will produce energy (power plants, etc), which
will be used by other buildings (factories, etc). To enable/disable this mechanic,
you just need to edit this toggle in Game Settings (you can find it in top menu -
RTS Starter Kit or just search Storage file, will be described below):
So, if a player is out of electricity, his units productions will be disabled or slowed
down until electricity will not be restored.
Change adding or using by units electricity you can in Unit Data of needed units:
You also need to add an Electricity Module to any unit, which adds or uses
electricity. By generating a unit prefab it should be done automatically.
Asset dependencies
Asset uses Post Processing Stack v2 for better graphics, so if you don’t add it in
Package Manager or by other way, it will not work. To add it from package
manager, select in Unity top menu Window > Package Manager, in opened
window do next steps from screenshot:
Known Issues
Package Manager UI problem (a lot of errors in console)
Caused by old dependencies (to support previous Unity version). You need just
remove Package Manager UI from Package Manager:
Same issue can be with the Unity Collab - remove or update Version Control
package in this case.
Buildings have one feature – building drawers. This is object, which shown when
player is in Build Mode:
You should set up it for every building, which will be available to build by the
player. To do this, you need to create an empty object, add a model of needed
building to it, and add the Building Drawer component to it. Next, drag’n’drop all
meshes of the building model to the Renderers field of Building Drawer. Finally, it
should look like this:
Finally, you need to click the Generate unit prefab button in the right part of the
window. After click, the created unit prefab will be spawned on scene and saved
in Prefabs/Units folder. A lot of it’s settings will be automatically configured, but
there still some params, which you should setup manually:
1. Unit colored renderers - parts of unit, which shows its house color (read
next partitions)
2. Collider size - size of your unit.
3. Fog of War module parameters - renderers/gameobjects of unit which
should be hidden when unit moves to fog of war.
You can don’t use these namings, but in this case you’ll need to setup all these
parameters manually (read next partitions).
In future there will be added more bones variations for automatic setup.
You also can use house color texture instead of coloring the whole mesh. House
color texture is same to emission texture, but it marks unit texture parts, where
should be drawn house color, for example, check Artillery unit:
Right image - house color texture, left - how it is drawn on the unit.
To use this type of house-coloring, you need assign unit model special shader
named Unit with House Color:
This approach can boost your performance and more flexible at all.
How to setup units with turrets?
If you have a unit, for example, a tank, you, of course, want its turret to aim
targets. To setup it, you need to check Has Turret toggle in Unit Data, and setup
Turret Rotation Speed greater than 0.
Next step is setting up of the prefab. There is one important thing. Turret of your
unit model should have the correct pivot. It should have aimed in the Z-axis
direction, same to Unity. How to check it? Select turret of your unit, select Pivot
& Local at top of the Unity Window:
Turret Transform field should contain bone of your turret or turret model itself,
depends on your modelling pipeline. That’s all, now the unit turret should work.
Note that UnitData Has Attack Module parameter also should be enabled.
Now your unit will damage the target directly (no Bullet/Rocket will be spawned,
field Attack Shell with attack prefab will be ignored). It still will use the Attack
Distance condition, which prevents attack from the distance above this value.
You should add all wheels to the array. If wheels have different pivot bone
settings, you should add new identical bones and make each wheel child for its
bone, and next add these bones to the array.
Rotation speed is in degrees in second. It means that in current settings (360)
wheels will fully rotate once per second.
Shell - create custom rockets and bullets
Shell is a bullet or rocket prefab, which will be used as a unit shooting object if
units have the Attack Type value set to Shell.
You can clone existing asset from the Prefabs/Shells folder and customize its
settings as you want. Settings are easy to understand - damage value, fly speed,
bullet lifetime and explosion effect:
To edit bullet physical size, change Radius value of the Sphere Collider. You can
use other collider types, if you need, just change the component. But this one is a
better to any calculations.
Animator Controller needed to allow animated character play its animations (our
asset will setup it to Animator in prefab automatically)
Use Animations says to the code that this unit have animations like move, attack
etc.
Now you need to make changes for infantry-specific needs in your unit prefab.
On automatic prefab generation it will do it, you know, automatically. :) But if
something goes wrong or you want to do it manually, you need to add Infantry
and AnimationsModule component to the unit prefab, and setup
AnimationsModule field Animator - it will allow unit to play animations:
This animator can be found in one of childs of prefab. If there no one in your
model, add it manually:
Setting up the animated character model is the same to the default Unity
pipeline.
After these things are done, it should work fine and play animations, if you added
it in your Animation Controller.
For more info you can check our asset example infantry soldier prefab, animator,
etc.
You can look for example abilities by searching the project for Abilities folder,
there will be one with scripts, and one with Data-files.
Ability script - is the core of any ability. It designed to be data-file, which
automatically handled in code of unit if you add it to UnitData of your unit:
New ability data can be created by right-click in Project Window menu and select
Create -> RTS Starter Kit -> Abilities -> “NeededAbility”
There are not so many ready-made abilities, because our primary target here is to
give you tool to create your own. It can be done by coding custom classes using
Ability as parent, you can see more info about it in the Programming partition.
We made API easy to use, so you should have no problems with understanding it.
Also there exists the Ability Editor window, which can be found in the Top menu -
> RTS Starter Kit -> Abilities Editor. It can simplify work with your abilities for a
bit.
How to add or edit Production Category?
To create a new production category, you need to right-click in the Project
Window menu and select Create -> RTS Starter Kit -> Production Category. But
you can clone existing in example project Production Category. You can find it in
Resources/Data/ProductionCategories.
Production category contains next settings:
1. Text id.
2. Icon of category. It will be drawn on UI.
3. Available Units - list of units (unit datas) for this category. It is all units,
which will appear on UI when this category is selected.
4. Is Buildings parameter. Check it, if this category contains buildings (not
units) objects. Otherwise remove the check mark from this toggle.
Don’t forget to add new production categories to specific faction, which should
have it:
Note that different factions can have the same production category, if you need it
for tests, prototyping or smth.
Also note, that in the current version it needed just to show production icons on
panel ingame, but if any building of this fraction will have non-added to faction
production category, on selection it still be able to buy units of this category.
After adding a new Production Category, add it to Storage object in Available
Production Categories field.
How to add and setup a new map?
First of all, you should create Scene with your map. This scene should have terrain
(or any object with collider and marked with Terrain layer), baked NavMesh (to
allow units move) and SceneBase prefab from RTS Starter Kit. Don’t forget to
place Player Start Points on the map (you can find this prefab in the RTS Starter
Kit Prefabs folder).
Next, you should add this scene to the Build Settings. After it is done, create Map
Settings (right click on Project Window, in the context window select RTS Starter
Kit/Map Settings), and fill its fields (map scene name, map size, players count,
etc).
Finally, drag and drop this Map Settings object to the field Available Maps of
Storage object.
To add a new faction/race you just need to create Faction Data and fill it with
your data.
To create new Faction Data, you just need to click RMB in Project Window, and
select Create -> RTS Starter Kit -> Faction Data.
Finally, you need add it to the Storage into the Available Factions field:
Fog of War
You can enable fog of war in the Game Settings/Storage asset file. Result shown
on screenshot:
This is a classic mechanic for most RTS games. Hides enemies units in fog, your
units have ranged visibility.
To change the visibility range of a specific unit, select it in the Units Editor or
select his UnitData file and edit the field named Vision Distance.
Note that fog of war max units count (which have vision in FOW - player and his
teammates units) is 1000. It can be increased in shader files manually, but not
recommended.
You also need to setup all units prefabs to work in FoW. Screenshot below shows
how to do it. You need add the Fog of War Module to the unit, next you need to
select model in unit hierarchy and add it to the list of hideable objects (Do not
add there unit prefab itself, it will break unit in playmode):
If you don’t do it or do it wrong, the enemy unit will be visible in the fog of war. If
you see something like this, re-check your unit Fog of War Module settings.
So, you can check Is This Map For Singleplayer toggle in Map Settings and your
map will work as a single player-only map.
Also you need to pre-setup this map players parameters in Map Settings. My
example looks like this:
Finally, you need add this MapSettings asset to GameController Map Settings
field on scene of your map:
But you always can look at our settings and make something like this, but with
proportion to your scale.
Example project already contains example SoundLibrary asset, and it also setted
up in Storage (you need drag and drop here SoundLibrary asset which you want
to use, or left it as it is and edit example SoundLibrary when you want to add new
sounds).
Currently it looks not the best, but can be edited as any array in Inspector: to add
new categories or sounds - extend the array size. After it is done, setup newly
appeared field as you need.
Sound Editor is just a quicker way to access currently used in project Sound
Library, you can open it from the top menu -> RTS Starter Kit -> Sound Editor.
If you want to use Sound dropdown in your code, just write [Sound] before your
Audio Clip variable.
Triggers
Triggers allow you to setup custom gameplay situations on your maps. It is a very
useful thing for singleplayer and campaign games (can be used in your multiplayer
implementation too, but of course requires improvements in code).
For example, imagine the situation, when computer AI should start attacking
player units after them moving in some zone setted up before. With trigger you
simple select which units should attack the player and select, where it should
move to meet player units.
Or, another example. Player units reaches some destination, where player should
build the base. You can give player a money with trigger or you can spawn
Command Center (or another building which allows to create other buildings), so
player continue playing, but now have the possibility to build the base.
Our asset includes implementation of such triggers.
To start working on triggers, open top menu -> RTS Starter Kit -> Trigger Editor.
You should do it on your map, not in the Lobby scene etc.
Trigger Editor allows you to manage map triggers, add new and setup all their
parameters. If you already worked in other editors like this, it should be very
intuitive for you.
Trigger Zone component allows you to create trigger zones mentioned before.
Just add it to the empty GameObject, setup Box Collider of trigger zone (size etc).
After this is done, in the Trigger Zone component you can select triggers which
should be called when this zone is being triggered. Do it in Triggers To Call field.
Note that if you will rename triggers, you need to update parameters in Trigger
Zones too.
There also exists a Trigger Condition, which allows you to filter things which
should call these triggers.
So Trigger Zone is not only used for check entering units, but you also can use it
to make trigger which wait some time after level start.
This is an example condition of triggering zone:
This zone will be triggered only if a unit of type Helicopter owned by player 1
(with index 0) enters the zone. It is very easy to use, isn’t it?
Our asset already have some ready-made triggers, conditions and we will add
new ones in updates. You also can code your own triggers (use existing as
example), it is not too complicated. Don’t forget to add your trigger name in the
TriggerType enum. Note that it also should end with Trigger word, but you don’t
need to include this Trigger word to a TriggerType name of trigger.
Example: trigger named TestTrigger should be added to a TriggerType as a Test.
Win Conditions
Available from 1.6.8 version
Win conditions mean condition when one of players teams wins. By default in
asset used classic RTS Destroy All Buildings condition. But there also exist Collect
Resources Amount condition. And you can easily code your own, check the
Programming partition.
To create new variation of existing condition, use this menu (right-click on Project
Window):
Will be created file like this:
To setup win condition on your map, open Map Settings and add it to this field:
Programming
You can check the accessible module for null, if you are not sure that it exist on a
unit object.
To send a new order to a unit, use selfUnit.AddOrder method. You can send
move, follow and attack orders:
Using of RTS Starter Kit events
Rts Starter Kit code contains a lot of events, which you can connect your code to.
It simplifies development of new features very well.
For example, you can do something when any unit spawned. You can receive info
about spawn by connecting to Unit.UnitSpawned (previously
Unit.unitSpawnedEvent).
It will once load component from unit owning this ability, and next you can get
any of your data in another ability code like this:
To create a new win condition, create a new class and derive it from
WinCondition.
There is an abstract method bool CheckCondition(out int winnerTeam), you need
to override it with your own. It should return true if one of the teams wins. Also
should fill the winnerTeam variable, so the asset will know which team wins.
Don’t forget to add CreateAssetMenu since this is a Scriptable Object and you will
need a way to create asset of your WinCondition type.
Final code can look like this:
You can add any parameters and it will be shown in the asset of your win
condition.
Creating custom AI
Available from 1.6.9 version
You can derive from AIController class and override its virtual methods with your
own logic. You can still use default logic and add only new, if you’ll keep some of
virtual methods not overridden (for example, HandleUnitsBuilding method, by
default it handles units production by AI, if you override it and don’t use
base.HandleUnitsBuilding(), AI will stop buying new units).
Our coding conventions
Actual from 1.7.0 version
We trying to be consistent with Microsoft C# Convention.
But our code has some own conventions:
- We do not use a private modifier, since it gives no useful info to the user,
but increases code size and reduces readability in our opinion
- We do not use any prefixes in code like “_” or “m_”, since they reduce code
readability in our opinion.
Some code places can be inconsistent, because the first version of the asset had
bad conventions, similar to Unity’s ones, and it hard to change without breaking a
project for users (for example, ScriptableObject serialized fields,
FormelySerialized doesn’t fully save from serialization problems).
Roadmap
Possible roadmap for the next versions. You can read it, if you are looking for
some feature, but the RTS Starter Kit asset doesn't have it now.
Relevant roadmap can be found here: https://trello.com/b/50aM7pH1
Contacts
You can ask your questions or send your suggestions to us. ☺
To contact us use email [email protected]
Credits
RTS Starter Kit by Insane Systems.