-
Notifications
You must be signed in to change notification settings - Fork 2
Rendering on screen
SWZ edited this page Mar 14, 2021
·
1 revision
To make sure this works, enable rendering under the extra menu in the gui.
const { Client, Manager, Color, Vector3 } = require("EasyRLBot");
class ExampleBot extends Client {
constructor(...args) {
super(...args); // Do not change this except if you know what you are doing.
}
getOutput(gameTickPacket, fieldInfo, ballPrediction) {
this.renderer.beginRendering(); // Start rendering
// Render a string in 2D space
this.renderer.drawString2D(
0, // X coordinate (0 being in the left)
0, // Y coordinate (0 being in the top)
5, // X scale
5, // Y scale
"Hello, world!", // Text
new Color(255, 255, 255, 255) // White Color (ARGB)
);
// Render a 2D string at a 3D space position
this.renderer.drawString3D(
new Vector3(0, 0, 0), // New vector with coordinates (0 being in the center of the field)
5, // X scale
5, // Y scale
"Hello, 3D world!", // Text
new Color(255, 255, 255, 255) // White Color (ARGB)
);
let carLocation = gameTickPacket.players[this.botIndex].physics.location;
// Draw a line in 3D space
this.renderer.drawLine3D(
new Vector3(0, 0, 0), // Start vector with coordinates (0 being in the center of the field)
new Vector3(carLocation.x, carLocation.y, carLocation.z), // End vector with coordinates of the car location
new Color(255, 255, 255, 255) // White Color (ARGB)
);
// Render a 2D rectangle
this.renderer.drawRect2D(
0, // X coordinate (0 being in the left)
0, // Y coordinate (0 being in the top)
100, // Width
100, // Height
new Color(255, 255, 255, 255) // White Color (ARGB)
);
let ballLocation = gameTickPacket.ball.physics.location;
// Render a 2D rectangle at a 3D space position
this.renderer.drawRect3D(
new Vector3(ballLocation.x, ballLocation.y, ballLocation.z), // Vector with coordinates (0 being in the center of the field)
185.5, // Width of the ball
185.5, // Height of the ball
new Color(255, 255, 255, 255), // White Color (ARGB)
false // If the rectangle should be centered
);
this.renderer.endRendering(); // Stop taking inputs and send data to RLBot
}
}
let manager = new Manager(
ExampleBot,
3215 // This is the default port used by EasyRLBotExample
);