|
Post by magique on Nov 8, 2018 15:06:01 GMT
Is there a method for resetting an AI agent so that it can be used in a Pooling system? Right now when I re-use an agent from Pool Boss, the agent spawns dead. With Emerald AI there was a ResetAI function that could be used to put the AI back to its original state so it could be re-used.
If there isn't a built-in function, what would be the things I would need to reset myself, other than health, to insure the AI operates correctly for re-use?
[EDIT]
After further investigation I found there is a checkbox for Remove Components After Die, which is checked by default. I thought this might help by unchecking this, but not quite. Instead of spawning in the death pose, the AI spawns standing up, but it's health is negative, the capsule collider is disabled, and the NavMeshAgent component has been removed. So, it looks like this scenario hasn't really been considered. I'll have to hack the code to fix these this for now.
|
|
|
Post by magique on May 24, 2019 16:35:48 GMT
I'm closer to getting this to work, but there are still many issues. After fixing the bug in vControlAI.cs that was destroying the NavMeshAgent, resetting the AI's health, and re-enabling the CapsuleCollider, it nearly works.
However, the AI sometimes seems to randomly have NavMeshAgent disabled even if I specifically re-enable it on spawning. The same goes for the CapsuleCollider. Also, the FSM doesn't have any reset capability. Even if I Stop and Start it again, it sometimes is stuck in a Chase state and runs off into the game world chasing some non-existent target. This happens even if I RemoveTarget from the AI.
This is a very important feature and we need a fix desperately. Can we get some code that can do a proper reset of an existing instance of the AI. We do not want to create a new instance of an AI at runtime, but are using PoolBoss to spawn existing instances. They must be cleanly resettable.
|
|
|
Post by darthfarter on May 27, 2019 10:26:40 GMT
Hi. I have exactlty the same problem! I have adressed this in this post invector.proboards.com/thread/2237/reset-ai-after-death . The response i got from Invector was. "Just add health to your character". And that wont work if you disable and enable the character with all components being destroyed plus all the things that you mentioned as well. And the most annoying part is the bug with AI when you awake him from death and he keep running of in a straight direction running forever. Invector can you please look in to this.
|
|
|
Post by magique on May 27, 2019 14:23:28 GMT
Yeah, I saw your thread and their response about just adding health. It totally doesn't work. It needs some sort of proper function from Invector because there must be a lot of variables and states internal to these components that need resetting and I just don't know what they are.
Invector support is usually good, but they seem to be ignoring this issue and it's very frustrating.
|
|
|
Post by magique on May 27, 2019 15:07:42 GMT
I got a response from Invector on the Unity forums and they are looking at this. So, we might get a solution soon.
|
|
|
Post by Invector on May 27, 2019 15:08:07 GMT
We're not ignoring, but trying to create an easy way to do that and post here instead of a complicated way. Will post the fix soon.
|
|
|
Post by magique on May 27, 2019 15:11:14 GMT
We're not ignoring, but trying to create an easy way to do that and post here instead of a complicated way. Will post the fix soon. Thank you. I hesitated to use the word ignore, but this post dates back to November and no one from Invector responded so it seems like it was being ignored. I'm excited that a fix is forthcoming. It will be a game changer for us.
|
|
|
Post by Invector on May 27, 2019 15:49:26 GMT
I actually didn't saw the original post, sorry! sometimes I miss one or other thread. It's quite hard to keep up with forums, email support, youtube, etc...
|
|
|
Post by darthfarter on May 27, 2019 19:37:06 GMT
I actually didn't saw the original post, sorry! sometimes I miss one or other thread. It's quite hard to keep up with forums, email support, youtube, etc... No worries i can imagine all the work you do plus have to keep up with the forums. Glad that you are looking in to this. Keep up the good work. Thumbs up
|
|
|
Post by Invector on May 27, 2019 21:41:36 GMT
So... here's what we did to Reset the AI: In the vFSMBehaviourController script, add this method public virtual void ResetFSM()
{
// by set the currentState to null, the Update will automatically set the current state to Entry currentState = null;
}
In the vHealthController we already have a ResetHealth method, but it's missing the variable isDead which also needs to be reset. public virtual void ResetHealth() { currentHealth = maxHealth; if (isDead) isDead = false; } With those 2 methods we're able to Reset the AI after he died (also you need that quickfix that you posted here > invector.proboards.com/thread/2471/bug-vcontrolaiOf course, these 2 methods need to be called every time you do the Pooling effect and this can vary from pooling solutions, so you will need to create an Event to call this every time a poll is done, and if you need to reset anything else just create a public method and call using the same approach
|
|
|
Post by magique on May 27, 2019 21:45:10 GMT
I'll give this a try and let you know how it works out.
|
|
|
Post by magique on May 27, 2019 22:24:01 GMT
OK, so this doesn't work completely. I get about the same results as I was getting with the way I was doing it already. For some very strange reason, when the AI re-spawn, they navigate very oddly. They just start walking off straight ahead without stopping. And as soon as the NavMeshAgent gets to a point where it can't pass, it stops, but the character keeps on going through the obstacle. See image. Also, you also have to add the void ResetFSM() function definition to the vIFSMBehaviourController interface for your solution to compile.
|
|
|
Post by shadex on May 28, 2019 8:03:20 GMT
Is there a method for resetting an AI agent so that it can be used in a Pooling system? Right now when I re-use an agent from Pool Boss, the agent spawns dead. With Emerald AI there was a ResetAI function that could be used to put the AI back to its original state so it could be re-used. If there isn't a built-in function, what would be the things I would need to reset myself, other than health, to insure the AI operates correctly for re-use? [EDIT] After further investigation I found there is a checkbox for Remove Components After Die, which is checked by default. I thought this might help by unchecking this, but not quite. Instead of spawning in the death pose, the AI spawns standing up, but it's health is negative, the capsule collider is disabled, and the NavMeshAgent component has been removed. So, it looks like this scenario hasn't really been considered. I'll have to hack the code to fix these this for now. So why is this [URGENT] ?
|
|
|
Post by Invector on May 28, 2019 12:03:43 GMT
OK, so this doesn't work completely. I get about the same results as I was getting with the way I was doing it already. For some very strange reason, when the AI re-spawn, they navigate very oddly. They just start walking off straight ahead without stopping. And as soon as the NavMeshAgent gets to a point where it can't pass, it stops, but the character keeps on going through the obstacle. See image. Also, you also have to add the void ResetFSM() function definition to the vIFSMBehaviourController interface for your solution to compile. Here works fine, are you sure you're AI is spawning on a area with NavMesh? otherwise the design behavior is to turn off the agent and look for a navmesh area. The method goes to the vFSMBehaviourController as I mentioned, you probably added in the wrong script since we have 2 in project, open the one with the Icon.
|
|
|
Post by magique on May 28, 2019 13:03:13 GMT
So why is this [URGENT] ? Because it is a blocking issue and my game is far along and I need it to compete the game.
|
|