First scenario

First scenario

From BeamNG

Overview

Scenarios could have a pre-defined list of "goals" associated with vehicles. Each goal is automatically checked in lua. Different vehicles could have different goals in one scenario, scenario is successful only when all the entire vehicles’ goals are achieved at the same time. You should have a previous knowledge about how to create scenario if not go to Introduction to scenarios creation ..as start point you can download my_first_scenario.json

What are scenario goals?

  • Time: Scenario must be completed in X seconds
  • Damage: The required or the allowed car damage during the scenario
  • position: car needs to be at a specific position (potentially with a threshold)
  • Don't Move: car must not move from its initial position
  • Distance:
    • Min: Distance between two vehicles must not be lower than X.
    • Max: Distance between two vehicles must not be higher than X.
  • Speed:
    • Min-speed: Stay above speed as long as possible
    • Max-speed: Stay below speed all the time

First step you need before start defining your scenario goals is to open Json file and inside “Vehicles” table which contains names of your vehicles. Each vehicle should consists of two attributes “driver” and “goal

  • "driver": contains information about vehicle
  • “goal”: contains vehicle goals

1.png

What is the content of “driver” table?

vehicles table in json will contain all the vehicles in your scenario just add your vehicle name then inside "driver" table you should add this values

  • "player": is boolean value determine if this vehicle is play on non play "true" or "false" value
  • "startFocus":controls if that vehicle is focused (“true” or “false”)
  • "required":if the car can be removed by the scenario in multiplayer scenarios “true” or “false”
  • "ModeAI": used with AI vehicles could be either “flee” or “manual”
  • “command”: is any lua command. Here are the most useful commands :
    • "electrics.set_lightbar_signal(0)" : Turns off the light-bars
    • "electrics.set_lightbar_signal(1)" : Turn on the light-bars
    • "electrics.set_lightbar_signal(2)" : Turn on the light-bars and the siren sound
  • “AiAggression”: (number) Multiplied with the game's internal dynamic AI aggression value. The default internal value is 0.7 with a maximum of 1.0, so a multiplier beyond ~1.45 may not have any effect. Warning: high aggression will make the AI more faster and risky

10.png

What is the content of “goal” table?

Each vehicle has "goal" attribute, which could be customized with the following objects:

  • "timeLimit" attribute
this attribute is used to describe Time goal according to the values of:
  • "maxTime”: the time needed to complete the scenario (number)
  • "waitTime": wait time needed to check the goal status (number)
  • "msg": the message that would be shown on the screen (string)
  • “countdown”: the countdown timer that would be shown before the scenario end (number)

3.png

  • "damage" attribute
this attribute is used to describe Damage goal according to the values of:
  • "damageLimit": the minimum threshold of damage that could be maintained.(number)
  • "purpose": the purpose of the goal is either to "win" or "fail" the scenario
  • "msg": the message that would be shown on the screen

4.png

  • "position" attribute
this attribute is used to describe Position goal according to the values of:
  • "endpoint": string describes name of any objects in the scene tree (ex. waypoint name). which describes the location that the vehicle should be in.
  • "purpose": the purpose of the goal is either to "win" or "fail" the scenario.
  • "msg": the message that would be shown on the screen

5.png

  • "nomove" attribute
this attribute is used to describe Don't move goal:
  • "msg": the message that would be shown on the screen

6.png

  • "distance" attribute
this attribute is used to describe Distance goal according to the values of:
  • "maxDistance": maximum distance between two vehicles (number)
  • "minDistance": minimum distance between two vehicles (number)
  • "distanceEnable": (optional)start to check distance goal when the distance between two vehicles is X. (number)
  • "target": target vehicle that need to keep distance (“string”)
  • “msg”: the message that would be shown on the screen

7.png

  • "speed" attribute
this attribute is used to describe Speed goal according to the values of:
  • "minSpeed": vehicle speed should not be below this value(“number”)
  • "maxSpeed": vehicle speed should not exceed this value(“number”)
  • "maxTimeout": wait x seconds before checking goal status (“number”)
  • "wayPointNum": optional if you want to start checking speed at specific way points (array)
  • "purpose": the purpose of the goal is either to "win" or "fail" the scenario.
  • "delay": amount of time before start checking the goal needed when speed goal is for AI vehicles. (number)
  • "msg": the message that would be shown on the screen

8.png

  • “wayPointAction”
used when you want to show message on screen if user catch specific waypoints
  • "wayPointNum": an array of waypoints number
  • "wayPointMessage": an array of messages

9.png