Yea I’m also wondering how you would stop the state machine of an npc, so they do nothing anymore
Thanks so much for the continued work on this resource. I’ve used an earlier version (much modified to suit) on our Lost Friends game and found it great to use. Easily customisable and user friendly.
I am in the middle of rewriting and expanding our Monkey Poop game and needed to rewrite the old NPC crowd handler, so hopefully will be using this system.
A quick squizz through the code shows it’s fairly similar to earlier versions so we can easily customise once again.
Curious, can we stop a transition once it’s started? I’m wanting to be able to have panic NPCs and attacking NPCs with this.
btw I still don’t know how to disable the brain of an npc after it dies. If anyone has done it - let me know please
right now I just have checks if the humanoid is dead inside every state and its very ugly and buggy :\
Do u have a .rbxl file that duplicates the issue?
I don’t think its an issue, you may have misunderstood, Im just looking for a way to disable a “brain” (the ai script instance, or whatever it is) wnen my npc humanoid dies
and right now my solution is very very messy
I found the answer and I feel like an idiot now, there’s brain:Stop()
that is literally it…
Took me 4 month to find that jeez I’m blind
Ah lol, thanks for the reply ^^
So I’ve been trying to figure out how to set this up, and there is a clear lack of documentation which is causing me a big headache in trying to figure out how to use this system. My main issue is trying to figure out how to even set up the NPC areas. No matter what I try the NPC’s don’t seem to move at all. I tried tagging every object in the workspace, didn’t work. I tried creating regions using large parts, and tagging those, didn’t work either. The only thing that works for me is just tagging a baseplate on a fresh file.
All my NPC destinations are tagged “Justice:Pathfindable”. This can be found in the RandomPather module (if using Build 6). Any avoid area parts are tagged “Justice:Avoids”. I’ve get an example place with destinations and avoids if you want me to post it up here.
We’ve successfully implemented Build 6 into our new Monkey Poop game and it works well, except for the occasional error when it can’t compute a path, I suspect due to the map size and the destination is too far away.
How did you manage to achieve using brain:Stop(). When I look at the definitions in my brain StateMachine and Hooks, it has no ability to issue a Stop, and I just get an error generated:
I need to stop the brain to cleanly destroy the NPCs.
Are you sure you are calling it inside of the startStateMahine function because that’s where brain is defined
For those interested, I added the following to achieve the brain:Stop():
-- In main Justice script
-- Under function startStateMachine(model: Model) > transitions = {, add the following
{
name = "Dead",
from = { "Wandering", "Routing", "Idling" },
to = "Died"
}
startStateMachine(model: Model), add a :Dead hook
brain:Hook("Dead", function()
-- Remove brain and Model
brain:Stop()
brain = nil
game:GetService("Debris"):AddItem(npcModel, 5)
npcModel = nil
return
end)
You can then transition to this state using brain:Transition("Dead")
in the relevant part of your script.