I have two vehicles on different ways. One is faster and it will overtake the slower one.
If one vehicle passes the other one, a method should start.
How can I do this? I wanted to monitor the xdim variable, but this isn't possible.
Do i have to calculate this event on my own? Like 3m/s*x=1m/s*x+10m solve for x
The xpos variable is unwatchable value. You can try to use “ self.methcall(t) ” monitoring the xpos variable every t seconds. This is not the best way, but it can solve this problem approximately.
I think if anything you want to observe the "xPos" Attribute, as the xDim-Attribute refers to the loading-positions of the vehicle, not its position. However, xPos is also not observable.
With the cyclic methcall you can get an approximate solution (you can set the check-cycle to 0.0001sec, so it should be detailed enough), but note that
1) the xPos is measured in pixels, which also limits how exactly you can find the time you're interested in
2) if you check for fahrzeug.xPos > fahrzeug1.xPos then the vehicle will already be next to the other vehicle (unless you change the booking-points, as well)!
Another way would be to let both vehicles drive on the same track, create a collision-control ("Auffahr-Steuerung) in the faster vehicle and insert a "debug;". Then you could change your init-method like this:
is do -- slower vehicle starts 10 meters before the faster one .BEs.fahrzeug.erzeugen(Einzelstation); .BEs.fahrzeug1.erzeugen(Weg,10); end;
Now the debugger will open at the exact time when the faster vehicle would start to overtake the slower one.