Set up the Game World
Now that the player can spawn and control his units. You can proceed with adding other objects in the scene. Here are two examples
Add resource nodes
Adding resource nodes to the scene will add option for your collectors to gather resources.
You can do this simply by dragging the prefabs for resource nodes into the scene.
Make sure they have the correct layer for selection/interaction.
Now your units are able to collect those resource nodes!
Add enemy entities
To add enemy units, first you need to create Player again but this time for the enemy, and without selection, interaction or UI. Player by itself has no behaviour logic, those are managed by it's modules.
Units are controlled through Combat module; when they are to engage other units. Make sure this Module is present on the enemy player.
Now drag the Player prefab into the scene and assign it a Faction. This will now be our enemy player.
Define Enemy Faction units
One way to spawn units for the new Player is to define it's starting faction units and position it's spawn points as you like. This will make these units spawn on game start on the defined spawn point.
Define Player's Faction starting units
Configure Player's Unit Spawner
Drag units into the scene
Drag into the scene desired entities or units.
Assign player Owner (Player) to the added entities, this makes sure Player is properly managing it's own units.
Dynamic spawning (waves)
You can use the demonstration script WavesManager
to create simple waves of enemies with another Player as a target. This dynamically spawns pre-defined units and commands their attacks when units have no active task.
Create empty object
Add Waves Manager component, this will also add it's required Wave Unit Spawner.
Set Target Player, which waves of units will attempt to destroy
Set Bot Player, which is our enemy player
Configure times to your liking
Set up units that will be spawned in a wave and their numbers
Configure Wave Unit Manager by adding spawn points, this specifies where waves will be spawned.
Last updated