Game Development Reference
In-Depth Information
respawnTime = 0.0f;
GameObject newEnemy = Instantiate(spawnEnemy) as
GameObject;
newEnemy.transform.position = transform.position;
}
}
}
}
Now attach the preceding script to your Vortex object, populate the Spawn Enemy
field with the Enemy Prefab, and save the Vortex object as a Prefab. Scatter a bunch
of Vortex Prefabs around the level and you can get the hydra effect, where killing
one enemy will create two more enemies or even more than two!
Also, if you haven't already done so, you may want to go to the Physics Manager
option and adjust the settings so that enemies won't collide with other enemies.
One more thing—those enemies sort of glide out of their portals very awkwardly. Let's
boost the gravity so they fall faster. Click on the main Enemy Prefab and change the
Gravity Scale value of the RigidBody 2D component to 30 . Now, they'll fall properly!
Pro tip
There are so many things you can do with enemy spawners that go far,
far outside the context of this topic. Take a shot at adding some features
yourself! Here are a few ideas:
• Make the spawn vortexes play a special visual effect when an
enemy is spawned
• Give vortexes a range so that they only spawn an enemy if
another enemy was killed in their range
• Make vortexes move around the level
• Make vortexes have multiple purposes so that enemies can walk
into one and come out another
• Have a special gold enemy worth bonus points spawn after every
100 kills
• Make an enemy that, when defeated, spawns other enemies or
even collectable objects that earn the player bonus points!
 
Search WWH ::




Custom Search