Jump to content

  • Log In with Google      Sign In   
  • Create Account

A* Pathfinding and Collision Detection

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 piterh1   Members   -  Reputation: 105


Posted 29 July 2012 - 09:47 AM


I am currently working on a project for university and I have a couple of questions regarding collision detection. I am trying to change the A* algorithm so that instead of walking around obstacles it will be able to jump over the ones that can be jumped over. If you can't answer all the questions then please atleast answer the ones you know, it would help me greatly. Ok so here are the questions:

How is collision detection usually processed in games, do the objects all have bounding boxes for quick checks and more complex shapes for more accurate collision detection?

How do you check for collision with terrain, things like steep hills or a terrain wall?

How do you check for collision against invisible walls, are those just simple if < or > statements?

I need to know those things because if I am going to integrate the jumping ability into the pathfinding algorithm I need to check the trajectory of the jump so that the character doesn't collide with anything. Possible obstacles include holes, small objects, high objects, thin walls and obstacles on the jumping path.

Since I have no experience in writing AAA games I would really appreciate any information on how collision detection is done in those games so that I can make my project as professional as possible.

Thank you for your time :)


#2 IADaveMark   Moderators   -  Reputation: 3323


Posted 29 July 2012 - 12:57 PM

Are you asking about jumping over static obstacles or dynamic ones? If they are static obstacles, it is traditional to mark up your A* grid with that edge indicating the obstacle is jumpable.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI

Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

#3 jefferytitan   Crossbones+   -  Reputation: 2460


Posted 30 July 2012 - 12:01 AM

As Dave Mark said, you want to put as much of that connectivity information in your A* graph as possible. That means that your AI will rarely pick bad paths that can't be completed. It also potentially makes the game run faster because you did the checking in advance of runtime. It also allows you to easily handle things like ledges that you can jump off but not climb back up (one way edges), ledges that you can climb (you can traverse it, but the cost of climbing is higher than the cost of walking), etc.

The more physics and collision related stuff can be a pain, e.g. technically you can jump somewhere but in practice the character's head would hit a projection on the ceiling. There's a fine line between what belongs in pathfinding vs steering, and also between what glitches you allow and which you care about. I'm sure many games allow a character animation to momentarily pass through solid objects, even though the core of the character never does. The last thing you want is for a character's limb to get stuck on something and leave the game unplayable. That's one reason why simple collision shapes such as capsules are often used.

#4 piterh1   Members   -  Reputation: 105


Posted 02 August 2012 - 03:58 PM

First of all, thank you for the replies. I am focusing on static obstacles but maybe I should look into dynamic ones aswell to add some value to the project.

As Dave mentioned marking the points where the character can jump is the best option and I've already thought about it. However, if I just state that on my report I doubt I would get a good mark so I want to research other methods that find the jumping points without supervision. With this I would be able to say that, "I've looked at different ways of doing that such as this, this and this and I've concluded that this one is the most efficient...".

Jeffery, thank you for the information, I didn't think about things like allowing the character to pass through objects up to some extent but this will definitely help me with the project.

#5 jefferytitan   Crossbones+   -  Reputation: 2460


Posted 02 August 2012 - 05:40 PM

You could start with creating automatic links by making basic assumptions from the character's capabilities. For example, is the height difference between two cells <= the max height a character can climb? Would the fall from one cell to another cause the loss of less than all of the character's health? Using simple parabolic equations is it possible for the character to jump from one cell to the other at max speed and jump?

Once you have fulfilled the raw physical constraints you can start getting fancy. Reduce the level to a heightfield or voxels. For the jump situation is the lowest point between source and destination lower than the highest point of the character's jump? You can come up with lots of rules of thumb to whittle down the possibilities. They can err on the side of optimism or pessimism. If you err on the side of optimism, it may be an idea to dynamically alter the weights of edges every time you attempt a traversal which fails, e.g. you miss the jump. Otherwise your character will merrily leap off that cliff again and again and look like a broken robot.

#6 piterh1   Members   -  Reputation: 105


Posted 23 August 2012 - 08:35 AM

@jefferytitan The thing is I want the character to always be able to follow the path my algorithm finds so I can't have him fall or something. So in order to check whether the obstacle or hole can be jumped over I need to do collision detection on the path of that jump (apart from checking terrain height on both sides). I can't think of any other way to find out whether there is another obstacle on the jump's trajectory.

Well moving on, I have another question.

Is it possible to open new threads from within a thread?

I am thinking about running the A* and when it finds an obstacle that can be jumped over it will spawn another A* search on the other side (to see if it's not a dead end) while continuing with the first one. I know this will probably be useless because of the speed but I still want to try it.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.