Graphics Reference
In-Depth Information
With a path spawner system, the enemies never need to have any path names or way-
point objects hard-coded to them—it can create and guide any enemy capable of following
a path.
The prefabs/objects to spawn are stored in an array called spawnObjectPrefabs. This
array can be as small or large as you like—if there is more than one, use timeBetweenSpawns
to schedule each object one after the other.
There are two ways this script will begin to spawn objects from the spawnObjectPrefabs
list. One is to set the shouldAutoStartSpawningOnLoad variable to true, and the other is
to use a trigger system based on the position of the camera. In the example game Interstellar
Paranoids , the trigger system is used so that enemies do not appear until the camera (and
along with it the player) are within range.
Below is the Path_Spawner.cs script in full:
public class Path_Spawner : MonoBehavior
{
public Waypoints_Controller waypointControl;
// should we start spawning based on distance from the camera?
// if distanceBased is false, we will need to call this class from
// elsewhere, to spawn
public bool distanceBasedSpawnStart;
// if we're using distance based spawning, at what distance should
// we start?
public float distanceFromCameraToSpawnAt = 35f;
// if the distanceBasedSpawnStart is false, we can have the path
// spawner just start spawning automatically
public bool shouldAutoStartSpawningOnLoad;
public float timeBetweenSpawns=1;
public int totalAmountToSpawn=10;
public bool shouldReversePath;
public GameObject[] spawnObjectPrefabs;
private int totalSpawnObjects;
private Transform myTransform;
private GameObject tempObj;
private int spawnCounter=0;
private int currentObjectNum;
private Transform cameraTransform;
private bool spawning;
public bool shouldSetSpeed;
public float speedToSet;
Search WWH ::




Custom Search