smish.dev
aerial_hit

 

One of the most useful and impressive maneuvers in Rocket League is the aerial hit, where a car changes its orientation and feathers the boost in such a way that it intercepts the ball. Although it takes most people a while to develop intuition about how to aerial successfully, we will see that it is a very simple mechanic to implement for a bot. In particular, the following description will allow us to quantitatively determine:

Problem Statement

Let c(t) denote the position of our car, and f(t) be the unit vector in the direction the car faces, both in world coordinates. Additionally, we will take B(t),g to denote the accelerations due to boost and gravity (respectively), and P will be our target location.

For simplicity, we will assume that the car has already left the ground, so that we can focus our attention on just the dynamics of aerials.

Kinematics

The car's motion is described by an ordinary differential equation that includes contributions due to boost and gravity, and initial conditions:

c¨(t)=B(t)f(t)+gz,c˙(0)=vo,c(0)=xo,f(0)=fo

where z is the unit vector in the z-direction. We would like to find those functions B(t),f(t) that produce the trajectory that intersects our target at the prescribed time, Δt:

c(Δt)=P

Because the original differential equation is separable, we can directly integrate twice to get

c(t)=xo+vot+12gt2z+0t0τB(σ)f(σ)dσdτ

Now, we demand that the intersection condition is satisfied:

c(Δt)=P=xo+voΔt+12gΔt2z+0Δt0τB(σ)f(σ)dσdτ

Rearrange terms to group all the things we can control on the left side, and everything else on the right:

0Δt0τB(σ)f(σ)dσdτ=PxovoΔt12gΔt2z

Although this expression is very general, it isn't immediately obvious how to use it to determine our controls. What if we assumed that the car did the following:

  1. take some amount of time, 0<t<T, to turn the car so it faces a certain direction f, without boosting

  2. keep facing that direction, and boost with some constant acceleration for T<t<Δt

More rigorously: B(t)={00<t<TB0T<t<Δt,f(t)={q(t)0<t<TfT<t<Δt

If we put these expressions into the double integral above and simplify, we get:

12B0(TΔt)2f=PxovoΔt12gΔt2z

Dividing through by some constants gives us the working equation:

B0f=2(TΔt)2(PxovoΔt12gΔt2z)=A¯

Interpretation

Upon closer inspection, we see that each side of the working equation above has the dimension of acceleration. This means that we can interpret the right-hand side as the acceleration needed to arrive at target P in time Δt.

This means that B0=A¯ and f=A¯A¯

How can we tell if P is reachable by this maneuver?

Check if B0 is smaller than the car's actual boost acceleration (~1000 u/s^2). If the maneuver requires an acceleration larger than what the car can achieve, we cannotg et there in time.

How much boost will I need to complete this maneuver?

If we know the average acceleration, B0, and how long we will be boosting (ΔtT), then we know how long we will have to hold the boost button down, so we know how much boost it will take.

How do I feather boost to produce the right average acceleration?

Keep a running counter for the boost, and do something like this:

How do I make my car turn to the correct direction, f?

See: https://github.com/samuelpmish/RLUtilities/blob/develop/src/mechanics/reorient.cc

How do I freestyle with my bot?

To make contact with the ball, you only need to face the front of the car in the correct direction, meaning you can keep rolling as much as you want once the front direction is aligned.

Additionally, you can boost more than the average acceleration to make the necessary course correction in less time. Once the necessary acceleration is close to zero, your car is already on a "collision course", so you can stop boosting and just spin around in any direction you want.

Summary

To hit an aerial, use the working equation below to find the acceleration magnitude and direction required to make contact.

A¯=2(TΔt)2(PxovoΔt12gΔt2z)

where B0=A¯ and f=A¯A¯. If the directions are aligned (i.e. ff), feather boost to produce the right acceleration, B0, otherwise perform an aerial turn to align the car with the appropriate direction, f.