Reset enemies' pathfinding/LOS when unlocking doors?

Get help using Construct 2

Post » Mon Jun 27, 2016 5:03 pm

So I am making a stealth game (sort of), and I created these doors with locked & unlocked frames. When the player goes near it and holds E, the door unlocks & disables its Solid property if it is locked, and vice versa if it was unlocked.

However, I cannot get individual enemy objects to change its pathfinding to be able to go through the unlocked doors, or see through them (with line of sight). Is there a way to fix that somehow?

Thanks in advance! :D

Ps. An example capx file for the solution would truly make my day. :)
B
18
S
6
Posts: 32
Reputation: 1,261

Post » Sun Jul 31, 2016 10:38 am

Here you go.....Only a basic function...but it should help

includes basic patrolling enemy ..that will search /hunt the player when door is unlocked
arrow keys to control player and E to open RED door when standing next to it...

https://www.dropbox.com/s/1p1sa9xbjpnzapb/PATHFINDING%20THROUGH%20DOOR%20EXAMPLE.capx?dl=0


Also...The main reason why a pathfinding object may struggle to pathfind through an opening is due to its Cell size.
If the cell size is too large..
Some of the gaps between obstacles will have been closed off due to the cell size being relatively large compared to the size of the gap. BAsically what I mean is that the cells borders overlap creating the appearance of a solid obstacle.. This will make the pathfinding behavior find paths entirely around the obstacles, and never through them. You can help fix this by reducing the cell size but doing so often massively increases the computation time...Best method is to play around with cell size and Cell Border...Generally they should be the same...but often you can solve problems by altering these values in relation to each other..
Also ..its worthwhile to note that placement of obstacles can either streamline pathfinding or inhibit it.

Taking more care when designing your levels by making sure that gaps are large enough or as less complicated as possible will really speed up pathfinding computation time..

And never perform 'pathfinding' calls or 'Regenerate obstacle map' Calls Every tick....it will slow down your processing drastically.



For a better explanation...see here https://www.scirra.com/manual/154/pathfinding
When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
35
S
13
G
8
Posts: 318
Reputation: 7,685


Return to How do I....?

Who is online

Users browsing this forum: KTML5 and 20 guests