Tutorial
Creating a static body
- Click Create Rect and drag your mouse to create a body.
- Click Select and select the body.
- In the properties panel, uncheck the Dynamic checkbox.
- The body is now static, meaning that it will not move.
Creating dynamic bodies and joints
- Create two bodies via Create Rect. They will be dynamic by default.
- 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.
- Click to place the joint at your cursor's location.
- The two bodies are now connected by the joint.
- Please refer to the Box2D docs for more information about Box2D.
Editing bodies
- Click Select, then left click the parent body. The child body and joint are highlighted as well because 2DRL supports hierarchical objects.
- Move the parent body around by dragging it. You can see that the child objects are moved alongside the parent.
- Select the joint. Joints have no children. The green highlight indicates parent objects.
- Right click the parent body. The "recursive" buttons will apply the action to all of its children.
- 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
- Select the child body.
- 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.
- Select the joint.
- 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
- Click the button to the left of Train.
- Select a Python interpreter which has gymnasium, numpy, stable_baselines3 and pygame installed.
- Click Train. It should generate the environment and start training in a new window.
Saving/loading
- Click File → Save. It will be saved as a
.envscnfile. - Click File → New Scene. An empty scene should appear.
- Click File → Open, then choose the file that you just saved.
- You have now loaded your original scene.