Skip to content
JohnWL edited this page Oct 21, 2021 · 4 revisions

Enabling/disabling of rendering

When installing the RLBotGUI, rendering will be disabled by default. You can turn it on by clicking 'Extra' and ticking 'Enable Rendering' in the GUI. However, rendering can also be enabled or disabled any time using the page up and page down keys, respectively. So if your rendering isn't appearing, make sure to press page up before panicking.

Good to Know

Rendering in Java is a useful tool to draw information about your bot directly in RocketLeague, such as drawing the predicted ball path or the speed of your car. The Renderer in Java comes in two different versions. The first type is the normal Renderer found in rlbot.render.Renderer. This renderer is used with your current bot that is running and also has a maximum amount of drawing operations you can perform in one frame. The second type is the NamedRenderer found in rlbot.render.NamedRenderer. This renderer is mainly used for drawing large amounts of data on the Screen because you can divide your drawing operations into different packets and send them individually to RocketLeague.

Rendering with the normal Renderer

First we need to create a renderer, that we can use to draw on the screen. We can retrieve a Renderer object by calling BotLoopRenderer.forBotLoop(Bot bot) and then use it with the drawing operations. Let's take a look at this example code:

private void draw(Bot bot){
     Renderer r = BotLoopRenderer.forBotLoop(bot);
     r.drawRectangle3d(Color.white,new Vector3(0,0,0),10,10,true);
}

If we call this method in our bot's processInput method like draw(this) it should result in a white rectangle in the middle of the field. Something like this: white point

Rendering large Amounts with NamedRenderer

For rendering large amounts of data on the screen you want to use a NamedRenderer. For this you want to split your rendering into different parts that can be rendered seperately. Let's look at this example:

private void draw(){
     //Create a new rendering group
     NamedRenderer namedRenderer1 = new NamedRenderer("Group1");
     namedRenderer1.startPacket();
     //Render first part of data up to 100 drawing operations work safe
     namedRenderer1.drawRectangle3d(Color.white,new Vector3(0,0,0),10,10,true);
     namedRenderer1.drawRectangle3d(Color.white,new Vector3(0,0,100),10,10,true);
     namedRenderer1.drawRectangle3d(Color.white,new Vector3(0,0,200),10,10,true);
     //mark the end of your rendering part and send your drawing to RocketLeague
     namedRenderer1.finishAndSend();

     //Create a second rendering group
     NamedRenderer namedRenderer2 = new NamedRenderer("Group2");
     namedRenderer2.startPacket();
     namedRenderer2.drawRectangle3d(Color.red,new Vector3(0,10,0),10,10,true);
     namedRenderer2.drawRectangle3d(Color.red,new Vector3(0,10,100),10,10,true);
     namedRenderer2.drawRectangle3d(Color.red,new Vector3(0,10,200),10,10,true);
     namedRenderer2.finishAndSend();
}

First you create your NamedRenderer with a unique name. Then you have to start a new packet and after that you can safely do up to 100 drawing operations. If you exceed 100 you run into the same problems as the normal renderer. That's where the second group comes in and shines, because now you are able to do 200 drawing operations at the same time without breaking the game completely.

But this method of rendering can still be dangerous if used too much. For exmaple: This is what you do not want to do in RocketLeague

Clone this wiki locally