Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Make my own pathfinding system?

Author
Message
Mychal B
15
Years of Service
User Offline
Joined: 21st Jul 2010
Location: Coos bay, rainville
Posted: 13th Sep 2013 22:23 Edited at: 13th Sep 2013 22:23
Hey guys, I've got a question.

On my game I have obstacles that the enemy can not pass through "doors", and the enemy is always chasing you, so they have to find the route around the obstacles. The player can open the door, which means that the zombies pathfinding system needs to be updated, which takes nearly a quarter second! So I'm wondering if anyone has a workaround for this, or if it would be better to take the time to write my own pathfinding system? This has made a complete dead end in working on my game and is very demoralizing...
*using dark ai

The fastfood zombie killer
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 13th Sep 2013 23:53
We could make our pathfinder in the same way as a normal A star, but we have to update nodes every time we open or close a door. Some time ago, I made my own system ...instead of an infallible pathfinder, as we all know, the enemies will catch us sooner or later...what I made.. all enemies keep just a area, and if we were seen by the enemies, we leave a trail of way point behind us...let say five way points and the enemy start chasing this five wp ...and if at the end we don't hide ourself from enemies we were persecuted again...sometimes we thought that the enemy had it own intelligence with its mistakes as any human...every enemy will keep a new area, so we never know where the enemy will be next time. I don't have darkAI, but I guess that somehow it work more or less as I indicated.At the end when we get something on our own, we have a greater satisfacion.

Cheers.

I'm not a grumpy grandpa
Kezzla
17
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 14th Sep 2013 06:58
hmmm, Just some thoughts that may or may not work. some of them are simple so sorry if I am stating the obvious.

have you tried creating multiple containers with different obstacle maps for linear routs?

what about turning the doors into neutral ai entities on manual mode.
you can then leave the collision map unchanged and when the door is no longer blocking the pathway, the zombies can go through. they will sort of hang at the door trying to get through until it is opened. this may be a good option.

I will keep thinking about it.

@Chafari - That is an interesting idea for an ai hunting routine. I want to experiment with that if you do not mind.

Kezzla

Burn retina, burn!
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 14th Sep 2013 07:35 Edited at: 14th Sep 2013 07:38
I had also tried using the same method as chafari and it works out great. I used individual cubes as nodes and only drop them if required.

Nodes:
1. I place a single cube (max total 15) on the position of the player and constantly check a terrain collision from that cube towards the player.

2. If the player goes behind some sort of the terrain, a new cube is placed on the player's new position and the new cube now does the collision towards the player.

3. Repeat process 1~2. If cube count goes over 15, start re-using the cubes from 1. Repeat.

NPC:
1. NPC does a terrain collision towards player, if player is in sight and no terrain collision then move towards player.

2. If player is NOT in sight and there are terrain collisions then check new collision towards the last cube that was dropped. If that is clear then move towards that cube.

3. If the last cube dropped by player is not in sight then check the cube before that last cube. Repeat until you find a cube that has no collision.

4. While moving towards a cube, also constantly check if player is in sight and collision.

5. While moving towards a cube, If player is now in sight then change target to player. Rinse and repeat.


Here's a working example.
http://www.youtube.com/watch?v=EicR3F6TXcM


As for doors you can collision check for the door object when they get near it and perform the action.

Mychal B
15
Years of Service
User Offline
Joined: 21st Jul 2010
Location: Coos bay, rainville
Posted: 14th Sep 2013 08:50
Thanks for the replies everyone. Every room has a window that they can jump through to get in, but usually when they are inside they will wind up going through the doors, much like in call of duty zombies. The zombies will always chase the player, and they will always have a way to get to them. The reason why I can't set up the door as an entity is that the zombies wont take it into account in the path finding system.

The fastfood zombie killer
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 14th Sep 2013 09:12
About cubes: what if player will run in circles? Will NPC repeat that circles?

Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 14th Sep 2013 09:21
Quote: "About cubes: what if player will run in circles? Will NPC repeat that circles?"

No because the step that checks if the player is IN-sight and has no collision passes. So the NPC will just move towards the player. NPC only follows the cube if going straight at the player WILL get them stuck in some sort of terrain.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 14th Sep 2013 12:41
Quote: "@Chafari - That is an interesting idea for an ai hunting routine. I want to experiment with that if you do not mind."


Please feel free


@Ashingda 27
Nice example...I like it.


Quote: "About cubes: what if player will run in circles? Will NPC repeat that circles?"



I made the same as Ashingda, and that is why, instead of many way points, I just put five from the last point being seeing by the enemy...that's why the enemy looks like stupid bewildered when the way points ends ,and they do not see us.

Every time the enmy see us, will come straight to us, and just if we hide behind some obstacle the enemy will check for way points.


Cheers.

I'm not a grumpy grandpa
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Sep 2013 13:50
Some interesting ideas here.



Powered by Free Banners
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Sep 2013 01:33
Quote: "zombies pathfinding system needs to be updated, which takes nearly a quarter second! "


It shouldn't take that long to update the pathfinding map to say whether a block is open or closed. Door closes and it should be a simple matter of map(x,y).state = closed

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Sep 2013 11:33
Quote: "it should be a simple matter of map(x,y).state = closed"


You need more than that to update the paths - that's just the source data from which the path is calculated. If it's taking a quarter second then there must be a lot of nodes being processed - unless there's a problem with the code of course.



Powered by Free Banners
Mychal B
15
Years of Service
User Offline
Joined: 21st Jul 2010
Location: Coos bay, rainville
Posted: 17th Sep 2013 08:24
I'm updating it for at least 20 entities, and in order to add it to the pathfinding system I have to call ai complete obstacles I think it is, which is what takes so long. As far as altering the map content, if anyone knows how to access that info from dark ai please tell me!

The fastfood zombie killer
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 18th Sep 2013 11:28
Quote: "I'm updating it for at least 20 entities"


Wait, the number of entities isn't a factor in calculating paths. Are you re-calculating the path for every entity instead of re-calculating it once and letting all entities share the same path data?!

TheComet

horses
Mychal B
15
Years of Service
User Offline
Joined: 21st Jul 2010
Location: Coos bay, rainville
Posted: 20th Sep 2013 06:42
You know, I don't really remember why I put that there! I only call ai complete obstacles one time when I remove a object. My bad!

The fastfood zombie killer
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Sep 2013 13:17
I think something got lost in translation there.



Powered by Free Banners

Login to post a reply

Server time is: 2026-07-06 16:49:30
Your offset time is: 2026-07-06 16:49:30