Case Status
Log In


Home ยป Samples»Swamp»DemonManager FSM»Prespawn Demons
Community Wiki

Prespawn Demons


Pre-spawn all the demons that can appear in the scene.


Get Child Num

Iterate through all the children of SpawnPoints using spawnPointIndex .

spawnPointIndex starts at 0 and is incremented later in this state.

We store the child object found in the spawnPoint variable.

Create Object

Create an instance of the Demon Prefab at the spawnPoint found above.

Store a reference to the Demon object in the lastCreated variable.

Set Parent

Parent the demon to the spawnPoint. 

We do this so we can just activate/deactivate a spawn point to show/hide its demon.

Activate Game Object

Created objects are by default active.

We deactivate the demon since we want the scene to start empty, with no demons.

Int Add

Increment the spawnPointIndex by 1 so next time through this state we access the next child.

Int Compare

Check if we've used all the spawn points.

Compare spawnPointIndex against numSpawnPoints.

If Equal, we're finished and can move on.

If Less Than, we repeat this state until we're finished.


Last modified on 12/16/2010 3:35 AM by User.

  • RSS Feed