Tutorial

Creating a static body

  1. Click Create Rect and drag your mouse to create a body.
  2. Click Select and select the body.
  3. In the properties panel, uncheck the Dynamic checkbox.
  4. The body is now static, meaning that it will not move.

Creating dynamic bodies and joints

  1. Create two bodies via Create Rect. They will be dynamic by default.
  2. Click Create Joint, then select a body, then select the other body.
    • The first body will be the child, and the second the parent.
    • Each body can have at most one parent.
  3. Click to place the joint at your cursor's location.
  4. The two bodies are now connected by the joint.
  5. Please refer to the Box2D docs for more information about Box2D.

Editing bodies

  1. Click Select, then left click the parent body. The child body and joint are highlighted as well because 2DRL supports hierarchical objects.
  2. Move the parent body around by dragging it. You can see that the child objects are moved alongside the parent.
  3. Select the joint. Joints have no children. The green highlight indicates parent objects.
  4. Right click the parent body. The "recursive" buttons will apply the action to all of its children.
  5. Click Delete. You can see that the joint remains.
    • Joints are not required to be attached to two bodies.
    • However, any joint without two bodies will be omitted from simulation and exported code.

Editing metadata

  1. Select the child body.
  2. In the properties panel, under Environment → Observation Space, uncheck Angular velocity.
    • Now the child body's angular velocity will not be part of the observation space.
  3. Select the joint.
  4. In the properties panel, change the name to abc_123.
    • The name will be the variable name in the exported Python code, so it must follow Python variable naming rules and must be unique.

Training

  1. Click the button to the left of Train.
  2. Select a Python interpreter which has gymnasium, numpy, stable_baselines3 and pygame installed.
  3. Click Train. It should generate the environment and start training in a new window.

Saving/loading

  1. Click File → Save. It will be saved as a .envscn file.
  2. Click File → New Scene. An empty scene should appear.
  3. Click File → Open, then choose the file that you just saved.
  4. You have now loaded your original scene.