How to update a link between 2 nodes when a door..

Community Forums/General Help/How to update a link between 2 nodes when a door..

RemiD(Posted 2012) [#1]
Hello, :)

For those of you who have experience with path calculation and path following with nodes and links :

In my current project, i have precalculated the position of the nodes and the links between some nodes.

But ! What i have not thought about until now is that there will be doors in some passages and these doors will be either locked or unlocked, so how i am supposed to disable some links where there is a door blocking the passage during the path calculation, knowing that my nodes and links are not associated with doors ?

I am not sure how to manage this, what do you guys do for this ?
Do you store a variable to take into account an obstructed link because of a locked/blocked door ?

Ok thanks !


Derron(Posted 2012) [#2]
you have at least 2 options:

1) each "node" has flags telling if "up/right/bottom/left" is blocked or "open"
(+) checking is done really easily
(-) each node has to store 4 vars (could be done all in one byte - 1=up,2=right,4=down,8=left -> 3 = up and right etc.)

2) nodes do not know about blocking elements - but each "step" is checked for validity (eg. "TDoors.checkBlocking(node1, node2)")
(+) redundant code is minimized
(-) path finding is doing more work than needed.


In most cases "1)" is the most easier way to do so.
Instead of storing "up is blocked" you could also store "onTheLeft:object = XYZ" etc. so lookup for certain doors is saved and therefor some performance is given back...

All depends on: amount of doors, amount of nodes etc.


There are surely more methods - but yeah, now you have 2 more to consider.

bye
Ron


RemiD(Posted 2012) [#3]
Derron>>
I can't really use the option 1 you suggested because i use nodes not positionned on a grid but around obstacles.

But this confirmed what i thought would be a possible approach :
To store a variable for each link of each node so the program will be able to check if the door is locked or not and decide to use this link or not.
2 values for this variable :
=0 the link is never obstructed by a door and thus no need to check.
>0 (Id of the door) the link may be obstructed by a locked door and thus need to check if the door with this id is locked or unlocked.
If the door is unlocked, use this link for the path calculation.
If the door is locked, do not use this link for the path calculation.

I think it will work.


Kryzon(Posted 2012) [#4]
For the sake of flexibility you could fashion something that takes multiple portals into account.

You may have the following case:



Where you have more than one portal blocking the same link.

So each LINK object should have a dynamic array field that stores all portals that intersect it - this may come down to several portals, or none at all. You find which portals cross each of the links in a pre-process step, when you're loading the level for gameplay.
During gameplay, whenever you consider a link for travelling you go through all portals in the link's "intersecting portals" array, and check if any is closed - if so, try a different path or have the actor stop and stay idle at a certain distance from the closed portal (as if he's waiting for the portal to open or something like that).


RemiD(Posted 2012) [#5]
Kryzon>>In my current project there will be one node on each side of each door so there is no need to add the functionnality you describe.
But thanks fo the suggestion.


Matty(Posted 2012) [#6]
Interesting thought for you: how long after a door changes state should an ai unit be aware that the path is no longer valid?
1. Immediately
2. When they see the door/doorway
3. When a friendly ai tells them
4. When they hear the door state change?

Something to consider.


RemiD(Posted 2012) [#7]
Matty>>Ah ! Another challenge !
Let's say a character has already calculated a path to its target, and one door which was unlocked at the time of the path calculation becomes locked when the character is following the path.

Hum... I guess a possible approach would be to let the character follow its path until he reaches the locked door, and when he becomes aware of this, to make him calculate another path.

I don't think this will be a problem in my current project because the characters will only be able to calculate/follow a path to the player in the same room or to a door which goes to a room where the player was last seen or heard.

But if i want to add activities that the characters can do, this can be a problem and this makes another thing to consider : How much awareness of the environement of a World/Zone/Room a character should have ?

When i want to go to specific room or to get a specific object in the environments i know, i know which path to follow, but when i don't know the environements, i don't know which path to follow.
If i have a key, i know i can go through a door possibly locked, if i don't have a key i know i may not be able to go through a door possibly locked, or at least not with the key (but i may be able to pick the lock or to break it or to follow somebody who go through the door or to knock and pretent i am a delivery man ;) ).

This can become very complex to consider all these parameters !