haikel
Junior vMember
i wanna be the very best ... like no one ever was.
Posts: 43
|
Post by haikel on Jan 12, 2017 17:02:35 GMT
I want the enemy to be deleted after a period of time after he died is there a way to do this ? thanks in advance
|
|
|
Post by Chronicman on Jan 12, 2017 17:14:20 GMT
|
|
haikel
Junior vMember
i wanna be the very best ... like no one ever was.
Posts: 43
|
Post by haikel on Jan 12, 2017 17:50:32 GMT
thanks alot
|
|
|
Post by Chronicman on Jan 12, 2017 17:52:45 GMT
Your welcome!
|
|
haikel
Junior vMember
i wanna be the very best ... like no one ever was.
Posts: 43
|
Post by haikel on Jan 12, 2017 21:36:14 GMT
:c not sure , but when ever my enemyAI dies , all the scripts attached to the EnemyAI get deleted btw I used your code that you posted here using UnityEngine; using System.Collections; public class DestoryAI : MonoBehaviour { public float DestroyTime = 5; void OnDeath() { StartCoroutine(Death()); } IEnumerator Death() { yield return new WaitForSeconds(DestroyTime); Destroy(gameObject); } } NO compile errors , but it get deleted before he can run in the first place do I need to do what you suggest in the other thread post ? "Open up the script vRagdoll.cs, find the line 380 to 420 and comment them out by using // in front of every line. They will turn green you telling the compiler to ignore these lines." upload
|
|
|
Post by jgiroux on Jan 12, 2017 22:00:38 GMT
make sure if you are using a prefab to spawn the enemies, that you are saving(applying changes) to your prefab and *not* just the one in your scene.
otherwise when your scene enemy dies, it will just spawn a new *fresh* copy of enemyAI without the changes you made. common mistake for a lot of people.
also, if they are dying right away before even starting, make sure you have baked your navmesh for your scene. otherwise AI will trigger instant death so as not to error out the game. this is setup in Invectors normal code by default.
|
|
haikel
Junior vMember
i wanna be the very best ... like no one ever was.
Posts: 43
|
Post by haikel on Jan 12, 2017 22:27:00 GMT
I made an AI character using Invector Melee Combat and save it as a prefab (with all scripts attached to it) so when my enemy respawn , he respawn with DestoryAI script that Chronicman suggest and everything.
and yee , I baked the scene , the enemy go to waypoints and when ever I do something (kill someone - or steal a car) he start following me and attacking me
the AI controller works perfectly the only problem I have now if I kill an enemy AI their body still laying in the ground while the respawner respawn an other prefab after killing many of them , the game become slower and the fps drops so fast , since so many enemies still remain in the scene , I want to completely destroyed my enemy when ever he died
the only thing is , when an enemyAI dies all scripts get deleted as you see in the inspector
|
|
|
Post by yondaime08 on Jan 12, 2017 23:36:45 GMT
Does the a.I. script have a option to delete the dead enemy? Like how there is a check box for that for the player character. If there is might wanna double check to see if the box is checked or not.
|
|
|
Post by Chronicman on Jan 13, 2017 1:26:25 GMT
Did you check the v_AIMotor ? It has a function just like the ragdoll. Commenting these out should resolve you problem.
|
|
haikel
Junior vMember
i wanna be the very best ... like no one ever was.
Posts: 43
|
Post by haikel on Jan 13, 2017 7:24:05 GMT
yondaime08 '-' that could be an easy solution I can make a gamecontroller for every spawned character - and when ever my char dead the game controller will destroy that charechter for me a spawn it again I might try that thx (but it might be not practical because I'm using a spawner ) Chronicman well , I didn't , I'll check that now and see if it solve it :D thx for helping me out guys ^^
|
|
haikel
Junior vMember
i wanna be the very best ... like no one ever was.
Posts: 43
|
Post by haikel on Jan 13, 2017 7:36:47 GMT
Chronicman there is no DestroyComponents in the V_AIMotor :L
|
|
haikel
Junior vMember
i wanna be the very best ... like no one ever was.
Posts: 43
|
Post by haikel on Jan 13, 2017 7:52:49 GMT
I found it it called RemoveComponents I commented them out , and now my enemy components don't get deleted when ever he die but , your script didn't work :c , they enemy still on the ground
|
|
|
Post by Chronicman on Jan 13, 2017 14:58:53 GMT
I found it it called RemoveComponents I commented them out , and now my enemy components don't get deleted when ever he die but , your script didn't work :c , they enemy still on the ground Did you invoke the void onDeath with the vonDeath event ??
|
|
|
Post by fenderesp on Nov 21, 2020 14:01:58 GMT
I found it it called RemoveComponents I commented them out , and now my enemy components don't get deleted when ever he die but , your script didn't work :c , they enemy still on the ground Did you invoke the void onDeath with the vonDeath event ?? i"m not sure if it is correct but it can use adding public before void OnDeath() instead of the old one but it works cause the function choosen
|
|