Raised This Month: $51 Target: $400
 12% 

"Best" way to move NPCs ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bboygrun
CHOMP
Join Date: May 2010
Location: France
Old 07-21-2014 , 05:02   "Best" way to move NPCs ?
Reply With Quote #1

I saw the different ways to move a NPC but i wonder if it is better to use Waypoints OR A* Pathing.

A* Pathing is really nice but it calculates too much things and if there are like 30 NPCs in the same time, i don't even want to think how it would be :p

Then, IMO i must use Waypoints, in this way : (A lot of waypoints)



Here is the method i thought about :

If the player is visible to the NPC (nothing is between them) then i won't care about the waypoints and the NPC will directly follow the player in straight line, otherwise i'll have to find and create the best path with the waypoints and then check (let's say each seconds) if the player is visible to the NPC.

But i don't know if i should put explicit links between waypoints, i.e : "Waypoint X links to waypoints Y & Z". This should improve the way to find path between NPC & player (Faster & Easier btw IMO).

To find the path i think i've to do these steps :
Find the "starter" waypoint which need to be the nearest waypoint with the NPC AND that a traceline wouldn't find any entity between the waypoint and the player.

Afterwards, once the "starter" waypoint is found, i will take a look at his links and take the waypoint link which is the nearest of the NPC, and so on ...
Then finally we'll have a list of Waypoints to follow, i.e : Player --> X --> Y --> B --> A --> NPC.

The "small" problem is when the player will move, i think i'll check each seconds if the "starter" waypoints isn't the same, if it's not then we'll calculate a new path, otherwise we'll keep the same path.

What do you think about it ? Do you have any other ideas ?
Anyway, if the execution time is fast and the method is reliable, let's say it's a good solution :-)

Thanks anyway, CHOMP.

(Sorry for my english if you didn't understand some parts)
__________________
bboygrun is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 07-21-2014 , 16:44   Re: "Best" way to move NPCs ?
Reply With Quote #2

I'm fairly sure waypoints are better in this case. Overall, A* algorithm should be more accurate, but waypoints can be pre-defined and they don't require that much CPU horsepower. If I'm correct, A* should be used more for dynamic paths, when you need to find a path from A to B at this exact moment.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
bboygrun
CHOMP
Join Date: May 2010
Location: France
Old 07-22-2014 , 04:40   Re: "Best" way to move NPCs ?
Reply With Quote #3

Yes, A* is more accurate, but when i see these results : https://forums.alliedmods.net/showth...09#post2154909

I doubt it's the method to use, even if i am going to do it in a module, it will be too long IMO.

Arkshine told me to combine both methods, i think he is right and i will use Waypoints when the distance is superior to a certain amount, otherwise i will use A*, i think the execution time of A* won't be a problem then :-)
__________________
bboygrun is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:13.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode