| zombie simulator: traffic rage |
|
| Wednesday, 17 February 2010 18:22 |
|
"This should be easy"! That's what I said to myself when I started coding the car control, to get them driving around the city. The first issue, as previously mentioned, was OpenSteer. Having overcome that, it was time to get the traffic to obey some rules. Getting these cars to avoid accidentally hitting each other was a nightmare! I can only assume I designed this the hard way, because I ended up in a situation where I had large blocks of if..then..else statements telling cars what to do at the different kinds of intersection, how to handle traffic lights, etc. and every time I made a change to add or tweak a rule, it caused unintentional havoc elsewhere breaking the previous rules I'd implemented, leading to mass pile ups. It got so bad, once I had all the basic driving rules in, all the cars were being incapacitated from damage within 60 seconds of starting the engine! You'd think it'd be easy, the roads are all at right angles, there's only two intersection types. I suspect my mistake was using OpenSteer for both road following and random path following. OpenSteer is rather loose in it's interpretation of what "path following" is, and cars will tend to drive a line that is the average of the path in the vicinity, so they'll both cut corners and take a slightly different line into corners every time. That is what made it hard to pin down the rules. For me to reach my goal, I need the cars to cruise around without unintentional accidents for at least 10 minutes... after many, many painful hours I've finally got that happening. Almost. I've just been able to run the engine for 10 minutes with only a single collision - nothing major, just a sideswipe, more like "paint trading" really. I can live with that. Hopefully I can move on to something more interesting now. Here's a video of a working intersection. I've drawn coloured lines (which are blurry in Youtube) between the traffic lights to show what colour the lights are since they'd be too hard to see. The cornering still needs a little bit of tweaking but I'm going to put that off until I've finalised the road width and texture. I also noticed that the youtube videos were running at half the recording speed... I guess I didn't realise that was happening because I'm so used to running it in the debugger in slow motion :) Dim lights Embed Embed this video on your site blog comments powered by Disqus |
