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.
No longer true.
Assign playerOwner(Player) to the added entities, this makes surePlayeris properly managing it's own units.Add AssignEntityOwnership component on enemy player and assign the units to it. This component will make sure that enemies are added to the player in the expected order.
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.
Last updated