Tuesday, June 9, 2015

ai - Looking for a good technique for character movement in hack&slash game


I'm making hack&slash game and I want my characters move like for example in Torchlight, Diablo, etc. Currently I generate set of nodes for all walkable areas of a floor. When I click somewhere player goes there through interpolated path of nodes. This doesn't look very natural. Player moves like a robot. Enemies also use this node system for movement and share the same issue but I have one more problem with them. When enemies detect player they go to him by a shortest path. Sometimes they use the same path and line up to the player instead of surrounding him. I don't know how to make enemies choose different paths and surround the player. Do you know how can I solve this problems? Maybe I should use different approach for character movement?




My current technique:


enter image description here





Torchlight screenshot:enter image description here


---UPDATE---


I want to know how to deal with these situations:


Situation 1, I have dynamic/static obstalces on my way


enter image description here


Situation 2, Enemies have the sam path to player ( get into queue to fight with us ) enter image description here



Answer



Steering Behaviours in combination with a navigation data structure.


There are a number of ways to do this, but that's the basic concept. It might be easier to use a navigation mesh so that you can apply pathfinding within each convex section.



If you're adamant about keeping a graph, you can use a Seek behaviour to each node in the path, rather than rigidly following a path from node to node.


Another method you could employ is Path Smoothing but bear in mind that this is fairly computationally expensive.


Hope that helps.


EDIT:


To help with your obstacle avoidance issues, use some sort of Obstacle Avoidance.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...