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

Predicting the state of the world ?

Topics: Developer Forum, User Forum
May 21, 2010 at 9:42 PM
Hi, I am currently designing AI for a platform game. Movement of characters in this game is done by applying impulse (vertical & horizontal) to the characters. In order to do pathfinding I need to compute, from a given starting location which location will be reached if I apply these impulses for a given amount of time. To sum up : endPoint = F(startPoint, horizontalImpulse, verticalImpulse, duration) I need to know F... Is there any way to do that easily with Farseer ? (If you have any suggestion about other way to design pathfinding in such a case they are of course welcome ^^ ) Thanks in advance, Stéphane
May 22, 2010 at 11:41 PM
If you don't care about collisions, you can just apply the equations directly. They're not too complex: F = m*a, so a = F/m. a = dv/dt, so dv = a*dt. v = dx/dt, so dx = v*dt. All up, v += F/m*dt; x += v*dt; where dt is the amount of time you apply F for. If you do want to accurately include collisions in your calculations, you've got a lot more work to do -- you'll need to clone the Farseer world and run it forward for the amount of time you need. You might also be able to use ray intersections to cheat a bit -- e.g., throw a ray forwards from the current position to the end position you predict using the direct equations and see if you'll hit anything. Hope that helps.
Aug 23, 2010 at 3:12 PM

Ok, I tried to apply directly the equations. However, to do efficient pathfinding in a platform game we need to take into account the collisions...

Assuming that I would want to clone Farseer world and to use it to test a way there are 2 majors issues :

1) Is it possible to run farseer in accelerated speed (like 100x or 1000x real time ?) or better ask to the engine "what will be the state of the world in 100ms ?"

2) I will basically have to clone the world every AI update (probably every 100ms), do you have any idea about how heavy it will be (the project targets the XBox) ?