Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

elasticMan

NPC motion paths

This topic is 6918 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can anyone suggest ways in which I can get my NPCs to move around the map in specific paths. Ideally, I would like my characters to have a few possible paths to choose from depending on what other characters are doing. My problem is I really don''t know how to go about writing code to set up such a system. Are there any tutorials or articles around that I can refer to? I have set up my scrolling map and got my player character working and moving beautifully and also I am displaying my NPC properly with correct animations but I am stubbing my toe on how to implement their motion paths. Any help will be greatly appreciated. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Hi,
this is just a thought, have not tried it, but hope it helps..

When talking about moving actors in a game, there is a certain bit of AI among. If your AI is based on movement paths (ie. go-to-buy-groceries, or attack-nearest-opponent), then when triggered those AI-routines should be able to look and calculate coorinates from your current map. Like, when fridge is empty, your john doe get''s on his feet running to the first coordinate on his way to the grocerie store. How to calculate these then?

Once I took a sneak peek to a book titled ''real time strategy games'', and it told me the following:
option one, trial and error:
/ / /X
/@/ /X/X/X/X/ /G
/ / / / / / / /

If @ (actor in question) is to go to G, and X is a blocked square, you could try to calculate with a technique I call braille-technique. In this one the actor in question does not see in front of it, you just are checking squares in desired direction trying to get to the point desired.
This of course is not good, even though relatively easily one could avoid squares where actor has already been.
Another way is to calculate vision (and I prefer this one over braille). In this one you first pick the point where you should go to, ie the store. and from there you start working directly towards the actor. If you get all the way to the actor, the coast is clear and your actor sees the target, but if not..
As you come to a obstacle check surroundings, and try to get around the obstacle, and take another aim. This way you could try to generate a movement path for the actor, and with a bit of polishing it maybe even looks smart, or atleast not-totally-whacko..

hope it helps,
mustaukko

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!