Car and CarState

The Car class is fairly intuitive, and contains both the physics data and CarState of a given Car.

class Car

Public Functions

Car(const Car &other) = delete

No copy/move constructors.

Car(Car &&other) = delete
CarState GetState()

Update our internal state from bullet and return it.

void SetState(const CarState &state)

Update our bullet stuff to this new state, replace our internal state with it.

void Demolish()
void Respawn(int seed = -1)
inline Vec GetForwardDir() const
inline Vec GetRightDir() const
inline Vec GetUpDir() const
~Car()

Public Members

CarConfig config
Team team
uint32_t id

Each car is given a unique ID when created by the arena Will always be >0 (unless you somehow reach integer overflow)

CarControls controls

The controls to simulate the car with.

struct CarState

Public Functions

void Serialize(DataStreamOut &out)
void Deserialize(DataStreamIn &in)

Public Members

Vec pos = {0, 0, 17}

Position in world space (UU)

RotMat rotMat = RotMat::GetIdentity()
Vec vel = {0, 0, 0}

Linear velocity.

Vec angVel = {0, 0, 0}

Angular velocity (rad/s)

bool isOnGround = true
bool hasJumped = false
bool hasDoubleJumped = false
bool hasFlipped = false
Vec lastRelDodgeTorque = {0, 0, 0}
float jumpTime = 0

Active during the duration of a jump or flip.

float flipTime = 0
bool isJumping = false

True during a jump (not double jumps or a flip)

float airTimeSinceJump = 0

Time spent in the air once !isJumping.

float boost = RLConst::BOOST_SPAWN_AMOUNT

Goes from 0 to 100.

float timeSpentBoosting = 0

Added to replicate minimum boosting time NOTE: Will be used even when we have no boost.

bool isSupersonic = false
float supersonicTime = 0

Time spent supersonic, for checking with the supersonic maintain time (see RLConst.h)

float handbrakeVal = 0

This is a state variable due to the rise/fall rate of handbrake inputs (see RLConst.h)

bool isAutoFlipping = false
float autoFlipTimer = 0
float autoFlipTorqueScale = 0

Counts down when auto-flipping.

bool hasContact = false
Vec contactNormal
struct CarState::[anonymous] worldContact
uint32_t otherCarID = 0
float cooldownTimer = 0
struct CarState::[anonymous] carContact
bool isDemoed = false
float demoRespawnTimer = 0
uint64_t lastHitBallTick = ~0ULL

Set to arena->tickCount when ball is hit Don’t change this unless you know what you’re doing.

CarControls lastControls = CarControls()

Controls from last tick, set to this->controls after simulation.