- Home /
How to make enemies spawn IN the ground without rising up automatically first?
I've seen a lot of questions about how to spawn enemies On the ground. I want mine to spawn in the ground and rise up after a spawning animation or something. Right now they spawn in under ground and immediately are transported to the surface so I dont get the effect of them spawning in and then burrowing out from underground, instead they just exist on the surface already. It is worth mentioning that they also have a Nav mesh agent and the nav mesh is on the same level as the ground. My other option is to make a child game object that is a mound of dirt that spawns in to cover them as they rise up. I'd like to actually have both of these because otherwise the dirt mound is going to be too high and look weird to just spawn that in, which is the same as the original problem of needing my enemies to spawn lower.
Answer by yonatanab1 · Feb 28 at 09:07 AM
you can just turn off their collisions and re-enable when the animation stops playing (or add an animation event for a certain moment).
You cant add animation events at the last like 30 frames of an animation. It doesn't process it. i dont completely understand why but thats why the solution doesn't work. They teleport to the surface too early. I tried a coroutine and calling the animation event earlier so it lines up with the end of animation, but that doesn't work either.
can you share what animated asset you are using for the enemies? if its not the collision issue, it could be something specific to the model.
I believe the problem is the navmesh that makes them teleport to the surface because this happens for all of my objects with a nav mesh agent, animated or not. The problem is I would just disable the nav mesh agent with an animation event and enable it again at the end of the spawn animation, but animation events are apparently broken and can't be called toward the end of an animation, nor can you call it earlier with a delay as the code seems inaccessible at a certain point of the animation. The one thing I've considered is making the animation split the last 2 or 3 frames into a new state that at the beginning of it, has an event to reenable the nav mesh. Haven't tried it because ive been working on other things while hoping someone would have a cleaner solution.
Your answer
Follow this Question
Related Questions
Trigger or Colission not work if inside volume 2 Answers
Navmesh problem with SpawnSystem 0 Answers
Scripts are being disabled during game play 0 Answers
Help moving turret shoot lasers 2 Answers
Increasing spawn rate over time 1 Answer