# Unity Is the use of path finding algorithms a good idea for dribbling in sport games

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

## Recommended Posts

Well I  have been working on a soccer game for the past few months ("still learning unity 3d. its my first game"). I have recently come across some minimum path finding algorithms in my studies ( Prim's algorithm, Djikstra algorithm, a*, fFyod etc). I have been thinking of adopting one of these algorithm into my game to help in the players navigating around the soccer pitch to reach the opponents goal. This algorithm will be used during player dribbling and the map will be periodically updated or i was thinking the dribbler will create a map  and decide which path to go to minimize resource usage. I know the best way of learning is trial and error but I would love some heads up on this one. So what do you think I should do

##### Share on other sites

It seems to me like you're going to get a lot of complexity for very little gain. If we ignore players for a moment, there are no obstacles with which the players can collide, so you don't need a path finding system to move them around. Now if we consider players, you have obstacles but their positions are changing so often you will have a challenge maintaining the graph used for path finding. You'd either need to constantly recompute paths, which means that most of the last computed path would have never been used, or you're going to need to do a lot of work to predict where players are going to be.

Think about a path as having two sets of constraints - static and dynamic. Static constraints are those that do not move, such as buildings or cars or whatever else can just sit there in your way. Dynamic constraints would be other moving objects or players. Minimum path algorithms are great with static constraints.

In handling dynamic constraints in path finding, you generally use various steering behaviors to avoid the collision, or you replan the local portions of the path. In your application, your static constraints are going to be essentially non-existent, and you will have a lot of dynamic constraints on a path. So the question is, if we need to use short localized paths or steering behaviors to handle all these dynamic constraints, and there are no static constraints, what does path finding get you?

I think steering behaviors are your best bet for this because they are more suited to constant re-evaluation and they are more localized than a path finding approach. If you check out the book "Programming Game AI by Example" by Mat Buckland, you'll get some ideas for combining steering behaviors and how to implement them to give you good results in a sports game. There is also a good amount of information online for steering behaviors, but it's usually for more simple actions such as Seek, Flee, Patrol or Wander. The book will give you information on the more interesting ones like Interpose, which is going to be useful when getting players to intercept a pass.

##### Share on other sites
In an AI I took class we implemented simple pathfinding once using repulsor and attractor fields meaning you can add shapes to grid that effect a flow vector for every other point on the grid. Enemies would push away for a short range, the target would pull from a very far range. Our pathing agents would simply follow the flow. It worked surprisingly well, although it wouldn't work at all in a maze but a soccer field really isn't a maze.

You could have different fields depending on the state of the player (ie, on defense vs on offense with the ball/without the ball). Also something to note, you don't calculate the entire flow field, just the single point where the player is.

##### Share on other sites

I wouldn't program path finding for a soccer game. I'm sure some AI decent logic can solve your problem.

##### Share on other sites

I don't see enough reason to do path finding in a soccer game. Soccer field is an open space that you can establish a line of sight from anywhere to anywhere. All obstacles in the soccer game are other players which are dynamic and bad candidates for caching and sharing their states, which can be very bad if every player is also doing his own path planning periodically. Steering behaviors seem more suitable for this type of game. The natural looking movement is also a nice bonus.

##### Share on other sites

I seem to be doing this often as of late, but i second the recommendation to check out "AI game programming by example" by buckland. In fact, it's probably one of the best "game dev" books i have seen on the subject. Matt actually does a soccer pitch as a multi agent sim. It would definitely give you a good starting point. the key points are that agents use steering behaviors (such as seek, interpose, and wall avoidance) to navigate the pitch.

##### Share on other sites
I would have liked to mark all your answers correct. Well Matt Buckland's book is the base of this project and I am trying to add to that. I have implemented the whisker technique, though not perfect its decent.

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 9
• 27
• 20
• 14
• 14
• ### Forum Statistics

• Total Topics
633387
• Total Posts
3011609
• ### Who's Online (See full list)

There are no registered users currently online

×