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

# Pathfinding with Farseer

 Wiki Link: [discussion:279287]
 wp7Developer44 Nov 13, 2011 at 5:31 PM I've been searching through the discussions on codeplex as well as google but cannot find anything on Farseer Physics and Pathfinding.  I was wondering if anyone has done any pathfinding (Using A* or any other Algorithm) with Farseer.  My game is a 2d sidescroller/shooter and I would like my enemies to be able to avoid obsticles (Static Bodies) in order to reach the Hero.  Does the Farseer Engine have functionality built in to help with this?  If not, can anyone point me to any tutorials or samples using farseer and pathfinding?  Many thanks in advance. HellGate Nov 13, 2011 at 6:06 PM thanks to MaskedPixel for showing me this blog: http://jaketastic.com/blog/heuristic-uninformed-realtime-adaptive-2d-pathfinding-using-ray-casting/ Pnikosis Nov 15, 2011 at 8:02 AM The Raycasting seems a good idea. Another option is to decompose your map in small squares (squares that repesent walls, and squares that represent empty space where the enemies can move through) and implement an A* algorithm. Another option is to create your "path map" in the map design. I mean, when you create your map, you add a layer or something else indicating where are the sectors where the enemies can move around, and which sectors connect to which ones, then it would be quite easy to imlement an A* algorithm to move the enemies to the sector your Hero is. This last approach is the one I'm using, here you can see a quick explanation. wp7Developer44 Nov 15, 2011 at 8:50 PM Thanks Guys, I like the idea of using a RayCast.  I havent dealt with RayCasts too much and cant figure out the below:  public void RayCast(Vector2 position, Vector2 heroPosition) {     float _fraction = 0; const float l = 25.0f; Vector2 d = new Vector2(l * (float)Math.Cos(Body.Rotation), -l * Math.Abs((float)Math.Sin(Body.Rotation))); Vector2 point2 = position + d; Engine.World.RayCast((fixture, point, normal, fraction) => { _fraction = fraction; System.Diagnostics.Debug.WriteLine(fixture.UserData + "-"); return fraction; }, position, point2); System.Diagnostics.Debug.WriteLine(_fraction); } ﻿I am using the code above which I followed from TestBed sample.  I call this RayCast method from my update but it seems like nothing from within Engine.World.RayCast is being called.  My points are all defined and debugging/stepping through this looks to skip anything from inside the RayCast. ﻿ ﻿ HellGate Nov 16, 2011 at 12:23 PM Edited Nov 16, 2011 at 12:24 PM Engine.World.Raycast( (fixture,point,normal,fraction) => {       if (fraction < minfraction)       {            minfraction=fraction;            closestFixture=fixture;       } }, position, point2); or set a boolean to false to check if the path os free