| Zombie simulator: pathfollowing |
|
| Friday, 05 February 2010 19:54 |
|
Well that was a hell of a lot of work. Don't let anyone tell you that coding games is easy! Since my last post I finished the full integration of opensteer and I was able to run some tests. I based the vehicle controller on the pedestrian demo that comes with opensteer since that came close to approximating what I was after. Unfortunately, the results weren't what I had hoped for and I had to do some pretty significant work to bend it into the right shape. The biggest problem was that opensteer smooths out corners making turning more realistic, which isn't really suitable for my zombie infested world, since it's full of right angles. I found that I had to pump up the steering force settings really high to get the cars to keep within the road boundaries, but in doing so, it introduced a really annoying shudder like all the cars had shot suspension. The second issue this caused was that when a car approached a corner, about 30% of the time it would execute a neat circle and drive back the way it came... ouch. Eventually I got fed up with tweaking settings to see what they did and simply stripped out most of the functionality built into the pedestrian class. I then implemented my own path generator which basically takes a vehicle's position and simply traces the road until it hits an intersection. The vehicle is then allowed to run this path, and when it reaches the end, a new path is generated and it all starts over. You can see the path that's been generated for each of the cars as the blue lines that appear and disappear overlaying the road. The next step is to tidy this up - fix the glitches, keep the cars on their own side of the road, implement brakes so that cars slow when approaching a corner (allowing a smaller turning circle for the sharp corners) and stop completely when approaching an intersection. I can see that I'm going to have to work some magic to get the traffic lights happening... All in all, it's taken a couple of days, but with opensteer implemented, it's now also available for powering the zombies and unfortunate citizens since vehicles and creatures share the same base class. Luckily I don't expect as much trouble with pedestrians as they only need to follow a rough approximation of the footpath and can turn on a dime. Having said that, I'm sure some sort of trouble will crop up... it always does. Dim lights Embed Embed this video on your site blog comments powered by Disqus |
