Sperry on 17/6/2018 at 07:54
Here's the situation:
Two rooms are connected by two hallways. One hallway is short and direct, but has a transparent object blocking any passage. The other hallway is longer and indirect, but is unobstructed.
If I put an AI in one room and the player in the other, the AI stupidly runs towards the player using the short and obstructed path. I desire the AI to use the longer, indirect, but unobstructed hallway.
In an effort to remedy this, I've added AI-->Utility-->Path avoid: block pathfinding and repel.
However, the AI does not change its behaviour.
What would be the best way to guarantee that an AI will choose the proper unobstructed path?
Unna Oertdottir on 17/6/2018 at 08:15
Alway put AI-->Utility-->Path avoid: block pathfinding on a object, but not on a AI.
Create a invisible object on the hallway (collision type: none). Could be anything with
-Render Type--invisible
-Physics--Model--Type--Obb#6
--Physics--Misc--Ai Collides with: true
and add this to the object
AI-->Utility-->Path avoid: block pathfinding
AI-->Utility-->Pathable object: true
Run pathfinding database.
Now the AI can't go through the hallway any more, but the player can.
Sperry on 17/6/2018 at 09:42
Quote Posted by Unna Oertdottir
Alway put
AI-->Utility-->Path avoid: block pathfinding on a object, but not on a AI.
Create a invisible object on the hallway (collision type: none). Could be anything with
-Render Type--invisible
-Physics--Model--Type--Obb#6
--Physics--Misc--Ai Collides with: true
and add this to the object
AI-->Utility-->Path avoid: block pathfinding
AI-->Utility-->Pathable object: true
Run pathfinding database.
Now the AI can't go through the hallway any more, but the player can.
Thanks for the quick reply. I hadn't checked block pathfinding. Also, I didn't know OBB type influences pathfinding. It works perfectly now. Thank you Unna Oertdottir!
ZylonBane on 18/6/2018 at 01:46
Quote Posted by Unna Oertdottir
AI-->Utility-->Pathable object: true
No, don't add this. This property tells the engine that an object can be walked on by AIs. It's used for object bridges and things like that.
Since this object only exists to influence the pathfinding database, there's no reason for it to exist in-game. Have it delete itself by adding a Delete tweq:
Delete: Halt: Destroy Obj; AnimC: Sim
DeleteState: AnimS: On
You could alternatively use Difficulty/Permit: 0 for this purpose, but that would only get rid of it for players. A Delete tweq gets rid of an object while testing in DromEd too.
Finally, since the object won't actually exist in-game, there's no need for the AI Collides With prop.
Unna Oertdottir on 18/6/2018 at 07:07
You can do what ZB suggested, it doesn't hurt :thumb: Under certain circumstances, it's necessary.
or just ignore it. There's no need to do it in this case.
john9818a on 18/6/2018 at 13:28
If you want to keep the AI out of the shorter hallway altogether and save an object you could make the hallway solid, run pathfinding and then make the hallway an air brush again.
I know this is besides the point but is there going to be a logical reason why ai aren't allowed to pass through the shorter hallway? Players will notice this if there isn't anything visible in the hallway and will think something is broken.
Yandros on 18/6/2018 at 19:03
John, there's no need to use the solid terrain brush method any more, what ZB suggested works the same way basically but it is much cleaner and you don't have to remember to do it before you redo pathfinding. I've been using that method for years now and even posted it as a tut to prevent AI from getting stuck or to avoid certain places on here a few years ago. I just take a rail post since it already has all the right properties and add a delete tweq to it as ZB mentioned. Works beautifully.
john9818a on 18/6/2018 at 23:27
Yeah I didn't read all the way through ZB's post but it makes sense. I can still see problems with this scenario though. The player could stop at the no-path zone and effectively halt the persuing guard. If there is an archer the guard might flee and leave the rooms to go get the archer. Sometimes I think too much but I try to consider every scenario. I'm not sure why Sperry wants this set up though.
ZylonBane on 19/6/2018 at 00:04
Maybe he just wants a scripted sequence of the AI running a certain set of trolpts and then chasing the player, but doesn't know how to do it
Yandros on 19/6/2018 at 15:03
Yeah I typically use this technique to keep AI from getting stuck on objects by making them take a wide berth, but if used in other ways it can certainly lead to situations where an AI will just stand there if the player is standing in a pathfinding "dead zone".