This project has moved. For the latest updates, please go here.

2D AI Platform

Topics: User Forum
Oct 26, 2009 at 9:42 AM
Edited Oct 26, 2009 at 9:44 AM

I've posted an identical post at I figured it would be good to post here too, since me and my team is using farseer-physics in our project.

Anyway, to the question. What I want to do is create a believable AI in my platform game. The most important thing I want to figure out is an effective way of calculating if the enemy has to jump, and if he can jump to another platform, up from a lower ledge, or down from an upper ledge. It would be nice if the AI knew that there are no objects in the way of his jumping-path too.  Is there a simple way to do this with farseer-physics?

How would I do to calculate this? Do I need a way to check my surrounding area or should i just send away a kind of "transparent projectile"  and check if there is a platform at the end of the line in some way or what? That's the biggest question I've got now.

Simple illustration. (the IMG-tag didn't work, so you have to paste it into your browser)

Oct 26, 2009 at 10:19 AM

This depends on the approach you want to make on your AI implementation. You could use a pathfinding algorithm, marking in your map different nodes (or sectors) with actions to execute to move from one node to another one (portals between sectors), or you could make a simple object detection using raycast to see if there is an obstacle nearby which needs to be jumped to avoid it. In my game I use a combination of both.

I created different zones in my map, so when the enemies need to move from one point to another, they use a simple A* implementation to see which is the shortest way to move from one zone to another (see this article: and this one: Each zone has information on which action the enemy has to execute to move from one zone to another (jump, walk forward, etc). But inside each zone (or sector), if they find an obstacle (casting a ray in the direction the enemy is walking), they make the proper jump to evade it. I'm planning to make a video to show how it works, so I can post it here if you want to.

Another approach, a little more complicated to implement but that doesn't need to create sectors in the map is this one:

Hope this helps :)