|
I'm trying to write a Javascript that will spawn X-amount of enemies from 4 different platforms. They will need to spawn at random times rather than all at once. I'm guessing that I will need to use a Random class to divide up the enemyPrefabs, and at different times as well. The level is finished when all enemies are killed. The tutorials I've found only deal with spawning one enemy dependent on range from PlayerObject. I'm thinking of having a Parent GameObject (SpawnPoints) with the script and each of the spawn points (spawn1-4) attached as children. This is my initial thinking for the variables:
Any links to tutorials or other help is appreciated.
(comments are locked)
|
|
Here's the code I came up with that will let you set up Random Enemies, spawnPoints, maxEnemies and min/max time to wait between each respawn. This works great but I have one hitch to figure out. Sometimes when the Enemy is instantiated, the model will randomly default to the base T-Pose with no components. Furthermore, any other instances spawned at that spawnPoint will also be locked in the base T-pose, overlapping. They have enough time to clear each other's location/spawnPoint so that's not it either. Any ideas?
(comments are locked)
|
|
I just added a component like this to a game I'm working on, and I'll explain what we did. Create a "Spawner" game object, and add various spawn points as children, placing them in the world wherever you want them. Inside of the "Spawner" object, you'd want to do something like this:
That gets all the transform components inside all of the children (which are your spawn points), and then instantiates a prefab at one of the spawn points randomly. Be sure to set the I like what you were getting at with the parent of the spawnPoints but couldn't get it working correctly. Used an Array instead. I learned a lot from your post though, thank you. I almost have it worked out with only one hitch to figure out. When the Enemy is instantiated randomly, them model will randomly default to the base T-Pose. Furthermore, any other instances spawned at that spawnPoint will also be locked in the base T-pose. They have enough time to clear each other's location/spawnPoint so that's not it either. Any ideas? Thanks again!
Mar 24 '10 at 08:47 PM
DigitalDogfight
(comments are locked)
|
|
oke, i tried some things. this one was the best working. but it still won't work properly please some advice thanx a lot
(comments are locked)
|
