Page 1 of 1

Road vehicle collision

Posted: 21 Apr 2008 04:25
by daniel3ub
I've been playing TTD for years, sometimes using just road vehicles (just for fun).

Sometimes I can see a loong road full of trucks and buses, and some of them running in the wrong way (the faster ones), overtaking the slower ones, and passing through the vehicles that are coming in the opposite direction.

Since we now have one-way roads, I think it would be interesting to implement road vehicles collision, "forcing" the player to use one-way roads so his/her buses/trucks don't start causing accidents when overtaking in heavy traffic roads..
What do you think about? This way, the road vehicles would behave as much as trains, forcing the player to think about "road management", cleaves, junctions and so on.

I'm no programmer, so I have no idea if this wold be easy or feasible.

Re: Road vehicle collision

Posted: 21 Apr 2008 08:33
by zypa
I guess this is quite hard to code. But I'm not a developer, too.

However, you may like Roujin's patch: Traffic Lights.
It adds some "realism" to crossings.

Re: Road vehicle collision

Posted: 21 Apr 2008 16:34
by belugas
I have not yet looked at the collision code of trains, but from what I know, is that it is a bit CPU intensive. To the point that only the head/end vehicle are checking for collisions, and not middle parts. So, if collisions is to be added to road vehicles, I guess that the performance of the game will gradually degrade, and by a lot.

And then, next question is : if done to road vehicles, should the same medicine be given to boats?
Don't know, to be honest.

Re: Road vehicle collision

Posted: 21 Apr 2008 17:00
by llevering
belugas wrote:I guess that the performance of the game will gradually degrade, and by a lot.
However there might be a lot of exceptions for checking for a collision. If a RV is on its own side of the road and if its not on a rail or road crossing for example a crash can never happen (of course it can crash by an overtaking RV, however only one of both needs to detect the crash I think). On a one-way road too there is no need for checking. I like the suggestion and for sure in combination with Roujin's patch.

Re: Road vehicle collision

Posted: 21 Apr 2008 17:39
by belugas
So what you're saying is that there are ways to make the CPU impact less important if proper checkings are been done.
It could be.
But I guess the only way to find out would be to actually test it.
Which is not something i fancy doing myself, to be honest.

Re: Road vehicle collision

Posted: 21 Apr 2008 18:03
by daniel3ub
Well, I was thinking about it, too, the exceptions.
When the RV are entering and exiting stations they always pass trough the others.
It really seems that this is more complicated than it looks at first glance :)

Re: Road vehicle collision

Posted: 22 Apr 2008 12:37
by sulai
daniel3ub wrote:(...) Since we now have one-way roads, I think it would be interesting to implement road vehicles collision, "forcing" the player to use one-way roads so his/her buses/trucks don't start causing accidents when overtaking in heavy traffic roads.. (...)
I think collision detection is quite complicated, even if it's only for the vehicle that is overtaking.

Another proposal to make "overtaking" more realistic and make one-way roads more important to the game:

Let a vehicle only overtake if there is no oncoming traffic. If a RV wants to overtake it must be sure, that for the time it needs to be on the wrong way, there will be no other vehicle on that lane. I think this is quite easy to check since oncoming vehicles can only be in a certain radius. It's not even necessary to check whether the oncoming vehicle really comes that way, because a real bus driver wouldn't know that too.

The sketch shows all oncoming traffic detected by a very simple algorithm which just checks: is there some vehicle coming toward me, or is it traveling away from me? The two vehicles marked with (!) will be detected wrong by this simple algorithm.

Re: Road vehicle collision

Posted: 22 Apr 2008 20:33
by daniel3ub
And, on top of this, to make things more "interesting", let's just add a random chance that the driver will overtake anyway, even if the algorithm says that it's not possible. Nothing greater than 1 or 2%, I think.

This way, the player can choose to not use one way roads, but more cars on the same road, more likely will be an accident.

Re: Road vehicle collision

Posted: 23 Apr 2008 11:12
by sulai
I just had a look at how overtaking works in the game right now.
  • The vehicle won't overtake if there are crossings. This isn't checked before: the vehicle starts overtaking and aborts doing so if there is a road crossing.
  • The vehicle will overtake if there is oncoming traffic.
So there are actually only two points to change:
  • if a vehicle wants to overtake, first check:
    • is there a crossing?
    • is there oncoming traffic?
  • ... and follow if it can't overtake
This will lower the capacity of two way roads and it will make one-way-roads more important.

Re: Road vehicle collision

Posted: 23 Apr 2008 12:29
by tb2571989
also, bear in mind that road vehicles using one-way roads at the moment only use the default left or right-hand setting and not both, as a 'dual carriageway' and something I'd like to see them doing.

Re: Road vehicle collision

Posted: 23 Apr 2008 19:40
by daniel3ub
Sure. the final result will be just like we drive here in Brazil: slower vehicles at the right lane, faster vehicles overtaking at the left lane. Then the one-way road could be used to trigger overtaking and collision verification off. If the RV is at a one-hand road, do not check to see if it's possible to overtake (or do not check for collisions).