|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
#1 |
![]() Join Date: Jun 2008
Reputation: 0
Posts: 14
|
Pathfinding in Source?
Well, here I am. I'm sure you can guess I have a problem, since I'm asking (:
Anyways, I have a little entity that runs around randomly at the moment. What I want it to do is find a path to the player and follow it, like the Zombie, using the node graph and whatnot. Well, I honestly have no idea where to start. I looked around the code for Zombie, Antlion, Combine Soldier, but I didn't really find anything that is of much use (that I know of...) so I don't really know where to start.. I would really like to know how it all works.. is the pathfinding ONLY for NPCs? (Meaning I'd have to make my own NPC), applies to anything? I'm so confused ![]() |
|
|
|
|
|
#2 |
![]() Join Date: Jul 2007
Reputation: 38
Posts: 2,152
|
It might be possible to hijack it, but the pathfinding behaviour is coded into NPCs, so the easiest way is probably to make a very simple NPC.
|
|
|
|
|
|
#3 |
![]() Join Date: Jul 2008
Reputation: 2
Posts: 143
|
I suggest you to play around with npc code, it's not so hard as you might first think. You should take a look at other npc code and then build your very own simple npc from the template which is monster_dummy.cpp
I found the zombie, combine and rebel npc code very messy so probably the best way to go is to use either monster_dummy or some sort of simple npc such as barney. Very good and detailed tutorial here http://developer.valvesoftware.com/w...mming_Overview and http://developer.valvesoftware.com/wiki/Creating_an_NPC Once you have a vision how npc's work just play around with your npc code and eventually everything related to npc code seems very clear. Last edited by sormii : 11-25-2008 at 01:52 AM. |
|
|
|
|
|
#4 |
![]() Join Date: Jun 2008
Reputation: 0
Posts: 14
|
Well, I guess I'll have to work with NPCs.. although I'm pretty confused by how they work. What I gathered from the tut on the VDC, was that the NPC first finds out what's happening around him, then it picks a state, then it selects a schedule.
The appropriate schedule, which is a list of tasks, is executed. It will continue to execute until it's either interrupted (by a defined interruption) or until it ends.. then it picks something else to do.. So.. am I right? |
|
|
|
|
|
#5 |
![]() Join Date: Jul 2007
Reputation: 38
Posts: 2,152
|
Sounds right to me
|
|
|
|
|
|
#6 |
![]() Join Date: Jun 2008
Reputation: 0
Posts: 14
|
Another question based on the NPC.. when it goes through that whole process and picks a schedule, made up of the tasks, it will go through them, and only end when all tasks are done (or is interrupted).
So, the NPC will not gather what's going on around him/pick state/select new schedule until the old one is done or is interrupted? So when he's interrupted it will just go through the whole process again? Meaning the whole process of finding out what's going on around him, picking the state, picking schedule only happens once in a while? |
|
|
|
|
|
#7 |
![]() Join Date: Jun 2008
Reputation: 0
Posts: 14
|
Well, I basically figured out the NPC, all it's schedules, tasks, conditions, etc.. I guess it really wasn't as hard as it looked
![]() But now I just need to figure out how to make the NPC follow the player around.. so pathfinding.. how does it work again for the NPC? ![]() |
|
|
|
|
|
#8 |
![]() Join Date: Jul 2007
Reputation: 38
Posts: 2,152
|
Basically yeah. He's constantly looking around him though, and setting conditions that may or may not interrupt him. For instance, an idle schedule will be interrupted by seeing an enemy, but a shooting-an-enemy schedule won't.
|
|
|
|
|
|
#9 |
![]() Join Date: Jun 2008
Reputation: 0
Posts: 14
|
Ok, well I'm back to the start now I guess.
Figured out the NPCs, got all the schedules to work and whatnot, but I can't figure out how to get the NPC to find a path to the player, and go through the path.. Help? ![]() |
|
|
|
|
|
#10 |
![]() Join Date: Jul 2007
Reputation: 38
Posts: 2,152
|
Something like this?
Code:
AI_DEFINE_SCHEDULE ( SCHED_FOLLOW_MASTER, " Tasks" " TASK_SET_FAIL_SCHEDULE SCHEDULE:SCHED_IDLE_STAND" " TASK_SET_TOLERANCE_DISTANCE 200" " TASK_GET_PATH_TO_PLAYER 0" " TASK_RUN_PATH 0" "" " Interrupts" ); |
|
|
|
|
|
#11 |
![]() Join Date: Jun 2008
Reputation: 0
Posts: 14
|
Doesn't seem to work. It's probably something I'm doing wrong with the NPC.. why do sparks spawn above it's head periodically? I'm sure that has something to do with this..
|
|
|
|
|
|
#12 |
![]() Join Date: Jul 2008
Reputation: 2
Posts: 143
|
I had some problems also a while back
http://forums.steampowered.com/forum...d.php?t=735294 |
|
|
|
|
|
#13 |
![]() Join Date: Jun 2008
Reputation: 0
Posts: 14
|
Ok, now I'm REALLY confused.. thanks to sormii (I think xp) the whole schedule system works. The NPC picks the schedule to follow the player and it's great, etc...
But it seems to have some issues with the tasks. Out of all the shared tasks, it will only do the ones that don't involve any moving around. If there's a task that requires moving, the NPC will sit there and sparks will spawn above it's head... ??? |
|
|
|
|
|
#14 |
![]() Join Date: May 2008
Reputation: 48
Posts: 3,944
|
I don't know much about AI/NPC-coding, but aren't there any warnings in the console?
If not, post your code. Other NPCs are working, right? |
|
|
|
|
|
#15 | |
![]() Join Date: Jun 2008
Reputation: 0
Posts: 14
|
Quote:
And there's nothing in the console. It's just the sparks, otherwise I would at least have some clue as to what is going on ![]() edit: I know that the schedule is working because one of the tasks is to face the player, and my NPC does that. It just won't move (wander doesn't work either) |
|
|
|
|
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Steam News Update Archive | sciss0rz | General Steam Discussion | 60 | 11-14-2009 01:26 PM |
| Source Towers Open Source | One3yed | Source Coding | 12 | 01-06-2009 11:18 AM |
| Source SDK Updated!!!! | TheArxinal | Source SDK General Discussions | 7 | 11-08-2007 06:28 AM |
All times are GMT -8. The time now is 08:59 AM.














Linear Mode

