|
Post by witchthewicked on Jan 1, 2020 1:33:52 GMT
After i kill an enemy, i need to make them recover health and come back to life. I have tried every method you expose. NONE WORK
Target = the GameObject that i killed.
The only way the AI comes back if i play with the currentHealth via the Inspector Editor. Watch the video please
insert code here private void ResetFighters()
{
player.GetComponent<vThirdPersonController>().ChangeHealth(100);
target.GetComponent<vControlAICombat>().ResetHealth();
target.GetComponent<vControlAICombat>().ChangeHealth(100);
target.GetComponent<vControlAI>().ResetHealth();
target.GetComponent<vControlAIMelee>().ResetHealth();
vControlAIMelee aiUnit = target.GetComponent<vControlAIMelee>();
target.GetComponent<vControlAICombat>().AddHealth(30);
vIFSMBehaviourController fsm = aiUnit.GetComponent<vIFSMBehaviourController>();
fsm.aiController.ChangeHealth(aiUnit.MaxHealth); }
|
|
|
Post by witchthewicked on Jan 1, 2020 2:31:56 GMT
Update, I solved it myself. This should NOT be the right way. Any thoughts would be appreciated.
vControlAI ai = target.GetComponent<vControlAI>();
ai.ChangeHealth(100);
target.GetComponent<Animator>().SetBool("isDead", false);
target.GetComponent<Rigidbody>().isKinematic = false;
target.GetComponent<CapsuleCollider>().enabled = true;
|
|
|
Post by witchthewicked on Jan 1, 2020 2:49:50 GMT
Update this actually didnt fix it, now i cant kill the enemy after i revived them. they just jog in place
|
|
|
Post by indennis on Feb 18, 2020 0:39:29 GMT
witchthewicked you can check out my post, I had a similar problem but found a very nice solution, this could work for you as well ;)
|
|