|
Post by cronikola95 on Apr 23, 2020 12:35:31 GMT
How can I make a spawner when my player passes through some collider then my enemy AI spawns in certain location?
|
|
Aaron
Junior vMember

Posts: 44
|
Post by Aaron on Sept 20, 2020 3:39:07 GMT
How can I make a spawner when my player passes through some collider then my enemy AI spawns in certain location? [See My Other Reply Below for a better version of this. It uses the same principles as this one but also turns your spawner off when you leave the area as well]
I decided to try this and this is what I built into my game.
(Hopefully you already know how to make the spawn system, if not check the demo scene in the FSM folder and see how they did it.)
Make a Spawn system as usual, and then disable it in the hierarchy.  Then make your colliders, set to triggers, and attach the Invector Simple Trigger script to it.
Open Events - On Trigger Enter - add the spawn system and set to GameObject / SetActive (Bool) and check the little box.
Now, when your character passes through the triggers your spawn system will activate and your enemies will spawn at the locations you set up in your spawn system.
|
|
Aaron
Junior vMember

Posts: 44
|
Post by Aaron on Sept 20, 2020 8:25:12 GMT
I found an even better method: Make your spawn system and place your spawn points where you want your enemy prefabs to appearand disable it in the hierarchy.
Then, make three or four colliders as shaped as walls to box in the area you want to trigger your spawn system. Set your Simple Trigger on your inside wall colliders to RunTimeOnly (Add your Spawn System) OnTriggerEnter / GameObject SetActive (Bool) and check the little box.
Then add 3 or 4 collider walls for the outside and set their triggers to RunTimeOnly (your SpawnSystem) OnTriggerExit / GameObject SetActive (Bool) and leave the little box unchecked.
As your Character passes through the outside trigger walls, nothing happens because it's set to turn off the spawner when you pass through it on the exit phase.
But when you cross over the inside triggers, your spawner activates because you've gone through on the enter phase.
As you pass back through nothing happens because you're trigger is already on. But when you pass through the outside wall you trigger the spawner off in the exit phase so your enemies wont respawn once you've left the area. 
|
|
Aaron
Junior vMember

Posts: 44
|
Post by Aaron on Sept 29, 2020 15:08:19 GMT
And an Edit to the last post: Everything the same as the above post, Except - 1. Inside your VAI Spawn (Script), check the box all of your Prefabs to Pause Spawning. 2. Inside your inside walls Simple Trigger, set the On Trigger Enter to AISpawn.StartSpawnAll. 3. On the outside triggers set them to AISpawn.PauseSpawnAll.
This should prevent them from respawning once you've left the area, but will respawn whenever you come back.
|
|