Problem with lap counting

Problem with lap counting

Postby Anon » 21 Jul 2014, 21:16

I believe I may have found another problem with cannons and lap counting.

When I export my track, the cannon section of scene.xml is placed in the wrong part of the file. As a result, to get lap counting to work at all, I have to move it to the correct location.

Once I do this, lap counting works as it should as long as the player stays on the track. However, if a kart crosses both checklines in order, and the proceeds to fall off the track and into the void, the game will act as if it crossed the lap line. I've tested this in both 0.8.1 and a 2 weeks old build.

I've attached a version of the track in question, with all the irrelevant parts removed.
Attachments
lapglitchtest.zip
(8.67 MiB) Downloaded 219 times
Anon
 
Posts: 208
Joined: 03 Jul 2014, 16:30

Re: Problem with lap counting

Postby hiker » 24 Jul 2014, 04:24

Anon {l Wrote}:Once I do this, lap counting works as it should as long as the player stays on the track. However, if a kart crosses both checklines in order, and the proceeds to fall off the track and into the void, the game will act as if it crossed the lap line. I've tested this in both 0.8.1 and a 2 weeks old build.
.

Yes, I could reproduce the problem. I have to look a bit closer why this is happening. Could you open a ticket in our bug tracker (https://github.com/supertuxkart/stk-cod ... state=open)?

Thanks!
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Problem with lap counting

Postby hiker » 24 Jul 2014, 14:39

Hi,

ok, a somewhat very specific problem: when a kart is off track, STK tries to find the closest quad it was on, based on the last quad it was on (or supposed to be on, if it was off track before). The algorithm for that takes the height of the quads into account ... to a certain degree: the kart must be at most 5 units above the driveline, and at most 1 unit below the driveline (this allows for some not exactly positioned drivelines, e.g. drivelines slightly above track will be tolerated).

On the other hand, we need to test for height (since otherwise in case of a bridge where a track runs on top of another part of the track would not work correctly (at least potentially)).

What now happens in your case is: the kart falls, so it's off track, and the above algorithm starts. Initially it will find the expected closest quad. But once it fell a bit further, the 'correct' quad is rejected, since the kart is too far below it. But the algorithm keeps on looking. It happens that your track is slightly going downhill in the section before the lap line. So, a quad further ahead of the kart will be picked as the 'closest' one (since it is lower, it still fulfills the height condition). Next frame,the kart will keep on falling, but it will keep on looking at the last found quad first ... which after a while will be discarded, and a quad even further ahead will be picked etc.

After a while the kart will finally be considered closest to the first quad again (which is lower than the quads before). Then the rest of STK will detect that apparently stk has crossed from a point before the lap line to the first quad after the implicit lap line, and count a lap.

Now, we can't just require that a kart must be on track in order to trigger a new lap. Well, we could, but we might break existing tracks, which have a somewhat narrower driveline defined, so crossing the line a little bit to the left would suddenly not be counted anymore.

One option would be relax the height test a bit, and e.g. allow a kart to be at most 2 units under the quads ... but that only shifts the problem, if the kart falls further, it will still happen. Or maybe we can just ignore the height condition, but then we have to find a way to pick the right closest quad if the kart is for example under quad A, and to the left of quad B - which one would be the right to pick?

Not entirely trivial ;)

But for now for you: you can either tilt the track a little bit, so that quad 0 is one of the higher points (or make the track flat). I think this is generally the case for our existing tracks (since karts should start on a flat part). Or you can add an invisible rescue plane (i.e. a plane that triggers a rescue of the kart if it touches it). Also adding terrain that just avoids that the karts can be too low there would avoid the problem (which is I think why we haven't seen this before). Since I don't know what you exactly want to do in those places - would that problem just go away if your track is finished? E.g. will there be a guard rail on the side, or a flat ... whatever?

Maybe I (or someone else) can come up with a better idea ;)

Cheers,
joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Problem with lap counting

Postby Anon » 24 Jul 2014, 16:14

Wow, complicated.

Thanks for the response. I've opened an issue on github and worked around the problem by adding a checkline right before the lapline.
Anon
 
Posts: 208
Joined: 03 Jul 2014, 16:30

Who is online

Users browsing this forum: Google [Bot] and 1 guest