|
Post by dartfarter on Feb 8, 2019 16:56:43 GMT
So i have killed my enemy and i want to reset it so its alive again how do i do it? Whitout destroying and instantiating, i am using activate/deactivate gameObject.
First problem i have is that the navmesh is getting destroyed? How do i prevent this? And if i add the NavMesh component it still complains about it.
How do you guys do it?
[EDIT] Ok so the system seems designed to not be able to deactivate the AI gameobject (When the AI is dead). I managed pull of killing the enemy disable the skinned mesh renderer so that it is not seen in the game, set the full health on the AI. Then it gets alive and get up from the ground animation, set a timer after 2 second (i guess after it has played get up animation) i then disable the gameobject. So at this point it seems that it works fine this horrific way but later when i enable the gameobject it forgets all about waypoint (allthough it has one still assigned) and just wanders straight forward forever.
How do you spawn the AI??? I cant find any information about this here or in the documentaion?
|
|
|
Post by dartfarter on Feb 12, 2019 7:56:30 GMT
Hi Can anyone help me out with this one? I need to reset enemy after death nothing more nothing less? I am using LeanPool right now and its working great except that it is spawning dead AI.
|
|
|
Post by cursedereaper on Feb 14, 2019 10:07:21 GMT
Can't help because not that many programming skills but there is a part of the script that removes the AI controller and all that stuff from the Object if it is death which might cause your problem. Altough it seams you already figured as much out.
There is a Spawn Enemy script in 1-2 included scenes which spawns a Prefab of the same type which might help. Assets -> Invector-AiController (Beta) -> Scenes -> And then you can find them in the Scenes AI_Spawner and AI_Arena. I don't recall how exactly it is done but you should be able to find all you need in there. Hope that helps.
In the NavMesh case one need to know if you bake it on runtime or if you bake it manual. When you bake it manual you shoudl deactivate everything that shouldn't be included in the Static Navigation mesh and put a Nav-Mesh Obstacle on that. Altough I don't know if that's actually your problem.
PS: I don't know what LeanPool is so I can't help in that regards.
|
|
|
Post by dartfarter on Feb 14, 2019 11:14:48 GMT
Can't help because not that many programming skills but there is a part of the script that removes the AI controller and all that stuff from the Object if it is death which might cause your problem. Altough it seams you already figured as much out. There is a Spawn Enemy script in 1-2 included scenes which spawns a Prefab of the same type which might help. Assets -> Invector-AiController (Beta) -> Scenes -> And then you can find them in the Scenes AI_Spawner and AI_Arena. I don't recall how exactly it is done but you should be able to find all you need in there. Hope that helps. In the NavMesh case one need to know if you bake it on runtime or if you bake it manual. When you bake it manual you shoudl deactivate everything that shouldn't be included in the Static Navigation mesh and put a Nav-Mesh Obstacle on that. Altough I don't know if that's actually your problem. PS: I don't know what LeanPool is so I can't help in that regards. Thanks man yeah those scenes instantiate and destroy those AIs and i try to avoid that. My NavMesh is baked as usuall no runtime baking(didnt even know you could do that). I am supprised that no one has done this or knows how its done since no one is anwsering to this.
|
|
|
Post by Invector on Feb 14, 2019 14:38:15 GMT
You just need to add health to him, if you didn't remove the components he will stand up again. Or you can destroy the dead enemy and spawn a new prefab (we have a spawn system, take a look at the "AI_Spawner" scene)
|
|
|
Post by cursedereaper on Feb 14, 2019 19:05:54 GMT
The bake Nav Mesh on Runtime is integrated in Unity since Unity 2017.04 but you could use it through downloading something from GitHub if you had a former version (works since Unity 5.6). When my programmer and I started we used 2017.04 and switching versions in Unity is a nightmare xD. This link should explain a lot about NavMeshs. When baking the Nav Mesh it can happen that it even select non static objects or use strange forms. I prefer to set the Nav Mesh via Colliders but that mostly includes the Player Model or the Enemies and leaf holes where they started (but the root of that lies within unity). I deactivate all my Enemies and players when baking my Nav Mesh and keep them in a Game Object as a Folder to organize my Scene.
My guess is that you're about the first that wants to keep the same Enemy Object because spawning a new Enemy of the same type is easy with the tools at hand and most users simply take that for their games and don't need something else. I guess your game wants the Enemy to keep certain stuff it collected over the course of the game like health Potions or Equipments or that it may be able to Level Up and it would be bad if the progress of the Enemy is lost.
|
|
|
Post by commanddan on Dec 15, 2020 20:15:20 GMT
My guess is that you're about the first that wants to keep the same Enemy Object because spawning a new Enemy of the same type is easy with the tools at hand and most users simply take that for their games and don't need something else. I guess your game wants the Enemy to keep certain stuff it collected over the course of the game like health Potions or Equipments or that it may be able to Level Up and it would be bad if the progress of the Enemy is lost. Late 2020 here to also attempt to keep the enemy AI for object pooling LeanPool is a tool made for object pooling. I don't use that here as I use my own implemented pool instead
|
|
|
Post by commanddan on Dec 15, 2020 20:20:24 GMT
You just need to add health to him, if you didn't remove the components he will stand up again. Or you can destroy the dead enemy and spawn a new prefab (we have a spawn system, take a look at the "AI_Spawner" scene) So I use the vHealthController's ResetHealth and it resets the health of the AI and the isDead but uhm well the body just lays and has no movement so it doesn't seem to be the case for me. Unless you mean explicitly using the method to add health. Haven't looked into what you have being called in there yet
|
|
|
Post by magique on Jan 25, 2022 20:37:19 GMT
AddHealth does not work. It seems to be alive and even acts like it kind of, but it fails to navigate the terrain anymore, just floating off into space, and it can't be killed anymore because the capsule collider is turned off, etc. Clearly there is more that needs to be done. Can you guys provide proper guidance on how to make this work? Your spawner demo just spawns once and does not re-use the AI so it's a poor example.
|
|