Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/java/rlbotexample/SampleBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import rlbot.manager.BotLoopRenderer;
import rlbot.render.Renderer;
import rlbotexample.boost.BoostManager;
import rlbotexample.input.CarData;
import rlbotexample.input.DataPacket;
import rlbotexample.input.car.CarData;
import rlbotexample.output.ControlsOutput;
import rlbotexample.prediction.BallPredictionHelper;
import rlbotexample.vector.Vector2;
Expand Down Expand Up @@ -75,6 +75,12 @@ private void drawDebugLines(DataPacket input, CarData myCar, boolean goLeft) {

renderer.drawString3d(goLeft ? "left" : "right", Color.WHITE, myCar.position, 2, 2);

if(input.ball.hasBeenTouched) {
float lastTouchTime = myCar.elapsedSeconds - input.ball.latestTouch.gameSeconds;
Color touchColor = input.ball.latestTouch.team == 0 ? Color.BLUE : Color.ORANGE;
renderer.drawString3d((int)lastTouchTime + "s", touchColor, input.ball.position, 2, 2);
}

try {
// Draw 3 seconds of ball prediction
BallPrediction ballPrediction = RLBotDll.getBallPrediction();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/rlbotexample/input/DataPacket.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package rlbotexample.input;

import rlbot.flat.GameTickPacket;
import rlbotexample.input.ball.BallData;
import rlbotexample.input.car.CarData;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package rlbotexample.input;
package rlbotexample.input.ball;


import rlbot.flat.BallInfo;
Expand All @@ -14,10 +14,14 @@ public class BallData {
public final Vector3 position;
public final Vector3 velocity;
public final Vector3 spin;
public final BallTouch latestTouch;
public final boolean hasBeenTouched;

public BallData(final BallInfo ball) {
this.position = new Vector3(ball.physics().location());
this.velocity = new Vector3(ball.physics().velocity());
this.spin = new Vector3(ball.physics().angularVelocity());
this.hasBeenTouched = ball.latestTouch() != null;
this.latestTouch = this.hasBeenTouched ? new BallTouch(ball.latestTouch()) : null;
}
}
29 changes: 29 additions & 0 deletions src/main/java/rlbotexample/input/ball/BallTouch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package rlbotexample.input.ball;


import rlbot.flat.Touch;
import rlbotexample.vector.Vector3;

/**
* Basic information about the ball's latest touch.
*
* This class is here for your convenience, it is NOT part of the framework. You can change it as much
* as you want, or delete it.
*/
public class BallTouch {
public final Vector3 position;
public final Vector3 normal;
public final String playerName;
public final float gameSeconds;
public final int playerIndex;
public final int team;

public BallTouch(final Touch touch) {
this.position = new Vector3(touch.location());
this.normal = new Vector3(touch.normal());
this.playerName = touch.playerName();
this.gameSeconds = touch.gameSeconds();
this.playerIndex = touch.playerIndex();
this.team = touch.team();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package rlbotexample.input;
package rlbotexample.input.car;


import rlbotexample.vector.Vector3;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package rlbotexample.input;
package rlbotexample.input.car;


import rlbot.flat.PlayerInfo;
Expand Down