Working with triggers
Triggers are a part of the builtin TMInterface bruteforce script that allow you to optimize a section of a track that does not consist of a checkpoint or a finish. A trigger is a cube placed somewhere on the map that acts as a point of an evaluation for the script. If the car enters the trigger, the state of the car is evaluated and the bruteforce script can accept a new solution, based on this evaluation.
Because triggers are a custom feature of TMInterface, they can be evaluated much more precisely than a simple finish/checkpoint time. There are different metrics available to choose how a trigger should be evaluated.
How do I place a trigger on the map for bruteforce to optimize for?
You can place the trigger by going to Settings Triggers tab and clicking the Add Trigger button. This will place a new trigger near your current vehicle position. From there you can modify the placement of the trigger either by modifying the Position and Size properties, or by using the Mouse edit option, to move the trigger around the map by using your mouse.
If Mouse edit is enabled, you can use these shortcuts to modify trigger placement:
- Ctrl+Q: moves the trigger’s position
- Ctrl+W: moves the trigger up or down
- Ctrl+E: allows to change the trigger’s size
Testing your trigger placement
The newly added trigger will be immediately visualized in the game. You can test your newly placed trigger by driving into the trigger area. If you have hit the trigger, the trigger will change its color and an information will be displayed in the console window about the hit:
[Triggers] Activated trigger 1 at 8.48 (velocity: 73.0647)
which in this case, means that the car has hit the trigger at 8.48s with a velocity of 73.0647.
Configuring bruteforce for optimizing your trigger
After successfully adding a trigger to your map, you are ready to configure the bruteforce script to optimize your trigger:
- Bring up the Settings panel, go to Bruteforce.
- Expand the Optimization header.
- Choose Trigger for the Optimization Target.
- Choose or add a new trigger that will be bruteforce.
- Set ratio to 0% which will make bruteforce evaluate the distance to the trigger.
- Launch the Bruteforce script.
This configuration will optimize for the distance metric, meaning that bruteforce will accept any solution that was closer to the trigger or reached it faster than the base run.
Optimizing a trigger has some key differences from other targets:
- If the trigger you have added was not reached by the base run at all, bruteforce will try to reach it first.
- After reaching the trigger, the further race is completely discarded. Bruteforce will not attempt to finish the run, but will always only optimize for the trigger.
- It is often required that the trigger is placed in an optimal spot, otherwise you may find out that the result is not what you initially wanted to achieve.
- It is likely that at the beginning of each bruteforce session you will get a lot of improvements quickly. This is because even the tiniest improvements are accepted by the script.
Evaluation metrics
As part of the builtin trigger evaluation, TMInterface allows you to define the tradeoff between distance and speed to the trigger. Setting the ratio to 100% will mean that bruteforce will only care about the speed of the vehicle once it entered the trigger. You can preview what a certain ratio means by hovering over the info icon that will appear besides the slider.
Managing triggers
You can see a list of triggers you have added in the Settings Triggers tab. To inspect which trigger corresponds to what placement on the map, hover the mouse over the trigger UI frame while being in a race. The hovered trigger will be highlighted with a green color on the map. You can also inspect triggers with the triggers
command:
triggers
which will display information about currently placed triggers:
Trigger 1: Pos (512, 9, 412); Size: (32, 8, 32)
If you need to edit a trigger you have placed before, remove it first by executing the remove_trigger
command:
remove_trigger 1
which will remove the first trigger added. While TMInterface itself supports adding multiple triggers to the map, the bruteforce script is not able to optimize for multiple triggers at once yet. After removing the trigger, you can add a new trigger with updated coordinates.