Alright, a few things. I'll order them by their relevance to your case:
WHY IT DOESN'T WORK
While you are creating a collision callback for the enemy, a path node is just a single point in the world. It is just a directional helper, a flag if you will, that the enemies use to calculate their path towards their destination. Collision can be calculated with things that actually take up space. Such as Script Areas.
Tell me more:
HOW TO MAKE IT WORK
Instead of referencing the last PathNode, create a script area there. The enemy will collide with that area.
WHAT TO THINK ABOUT
Enemies disappear on their own once far enough from a player & at the end of their patrol instructions.
(!) SCRIPT RELATED WARNINGS AND TIPS
- Your function "monster" isn't really telling you much about what it does. Consider changing the name (for your own sake) to something descriptive like "StartHallMonsterEvent"
- Based on general convention, Function names start with a Capital letter.
- Consider adding the Collide callback when needed, creating the enemy collision callback in the "monster" function itself.
- Your "CollideStop" function might be generalized. Meaning it could be called "EnemyDisableTrigger" and instead of
void EnemyDisableTrigger(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt", false);
}
can use the asParent variable to determine what to despawn. That would allow you to add the callback to any number of monsters you want, and each that would collide would get despawned.
// The parameters of this function can also be simplified (although not necessary)
void EnemyDisableTrigger(string parent, string child, int state)
{
SetEntityActive(parent, false); // Actually, the monster might be a child of the collision... Not sure there.
}