We highly recommend to start with the example project. It features:
A ready to go track using a landscape and splines
Offroad functionality
Predefined project settings (FXAA instead of TSR or TAA to reduce smearing, correct exposure etc.)
1. Download / Purchase the plugin on Fab
2. Install the plugin to the Engine
3. Download the Example Project here.
Important: To run this project, you must have purchased and installed the plugin to the engine. Otherwise, the project won't start/work correctly.
4. Unzip and open the example project
5. Open the Example Track level, and hit play!
6. You are ready to go.
If you do not want to use the example project, you can use the plugin normally in your existing projects as well.
Download / Purchase the plugin on Fab
2. Install the plugin to the engine
3. Find the plugin Content folder and use the BP_KartPawn BP
3. Drag the BP into any level and mark it as auto possess in the details panel. Or setup your own game mode logic and select the BP_KartPawn as the Pawn class.
4. Configure project physics settings
Go into your project settings, then scroll down to physics in the left side bar, and check "Tick Physics Async" and in "Async Fixed Time Step Size" enter "1/60" or "0,016667". (equals 60 Hz)
4. You are ready to go from here.
5. Bonus Tip: In your project settings, disable TSR and TAA and use something else, like FXAA for Anti-Aliasing. Otherwise, you will get smearing when drifting :)
This section goes over the bare minimum basics, that you will probably want to adjust to fit your use cases.
Basic explanation:
When using the included BP_KartPawn, the underlying drifting mechanic is used to implement drifting in stages:
When drifting, a drift is charged, starting at stage 0 (just some sparks are visible, when letting go no boost would occur). When holding a bit longer, the drift stage jumps to stage 1: A lot of blue sparks are now flying, and when letting go of the drift button, a boost will be applied.
To manage how long it takes for a specific boost to charge up, you can take a look at the Drift Stages setting below.
To configure different drift stages take a look at the details panel or the class defaults of the BP_KartPawn and find the "Drift Boosting" category.
Expand all child categories and then find the "Drift Boost Stages".
There you can:
Set how many stages there will be, by pressing the plus button or by removing an entry when clicking on the down chevron.
Set how fast the stage can be reached by adjusting the Boost Progress Threshold, basically how much "Charge" is needed to reach this.
Set the color of the sparks
Set the maximum speed increase as well as the acceleration increase. The defaults you can see on the right have sensible.
When drifting, the longer you hold the drift, the more you charge/collect. If you want to change how fast a boost is charged, you can use the "Drift Boost Collection Speed" variable.
To edit at what point each specific drift stage is activated, you can go into the drift boost stages and modify the "Drift Boost Threshold".
Note: If you do not need this style of stage-charging drifting, you can implement your own logic when of what should happen when starting a drift. The underlying C++ class provides drifting, aka. the hop, the slide into the drift, the drift handling and the drift correction after drifting, but it does not dictate if you want to blue sparks or sparks at all when drifting, or a boost or whatever you can see with the BP_KartPawn.
The BP_KartPawn is just a specific implementation of the underlying C++ class functions.
You may want to adjust the feel of drift in the standard BP_KartPawn.
For example, you may want the Kart to be able to make tighter or wider turns when holding the steering stick to the left or right.
To do change how exactly this feels, you just need to modify two curves:
Drift Curve
Drift Angular Velocity Curve
The Drift Curve dictates where the drifting force will be applied when drifting, relative to the gamepad's stick position. If the gamepad is held all the way to the left, we sample the point at -1 on the x-axis in the graph. If we hold the stick to the right, the point at 1.0 on the x-axis will be sampled. At 0.0 we would sample the stick when it is not touched.
The underlying code will reverse this mapping, when the drift direction changes.
Now regarding this drifting force, when a value of 1.0 is sampled in the graph, the drifting force vector will get calculated as driftingVector = 1.0 * sidewards vector + forward vector. Meaning, we get a roughly 45 degree angle.
If we want to make the Kart move more sideways or make it look like it lays itself more into a drift, we can increase the value to 1.5 or even 2.0.
1.1 achieves a classic Kart Racing look, which is why I chose it when trying to drift wider.
Similiarly to the Drift Curve, we have the Drift Angular Velocity Curve, which works in roughly the same way, but this time it's just about the rotation of the Kart.
Same thing as before: When holding the stick to steer inward when drifting, we are sampling the point at 1.0, when we hold the stick outward when drifting, we are sampling the point at -1.0.
The y-axis dictates how much forced-rotation should be applied at the specific inputs.
For exampling, when holding the stick inward, we want to be able to steer around tight corners, so we need to increase the torque. So we add a point at 1.0 on the x-axis with a value of 1.4. Likewise, when wanting to drift wider, we want to reduce the rate of rotation, so we set the value to something lower, like 0.5 at -1.0.
These variables can all be tweaked inside the BP's details panel or class defaults and should be largely self explanatory.
If you are wondering what the Air Acceleration Coefficient is: It basically scales the acceleration down by this factor when in air. A value of 0.0 means that the Kart can't accelerate while in air.
Acceleration is calculated in a specific way, such that it takes a bit of time for the Kart to reach it's Max Speed. This is essentially done by reducing the acceleration the closer the Kart is to the Max Speed.
The Minimum Acceleration Coefficient is a number that is used such that even at higher speeds, an increase in speed is always guaranteed (with this value), such that the Max Speed is reachable. When reducing this number, it is possible that the Max Speed cannot be completely reached. When making this number to large, you will always have constant acceleration, which also undesirable.
My tip: Activate the Print Debug Settings? variable in the details panel, and look at the current speed and see if you like the feeling of the Kart.
Turning is done by evaluating a curve. You can edit the curve, or insert a new one, similiarly to the drifting curves.
The curve is evaluated from 0.0 to the Max Speed that is set for the Kart. You can for example, set a low turning rate at low velocities and a higher turn speed at higher velocities.
When the Kart moves slower than In Place Turning Threshold Velocity, it won't be able to turn at all. This is useful so that the Kart won't be able to turn in place.
Turn Speed is just a turn speed multiplier.
Max Air Turn Speed is like Turn Speed, but when the Kart is in air.
Max Angular Velocity is the maximum angular velocity the Kart can ever have. Having an upper max angular velocity will make the Kart robust to sudden bumps and spins (for example with walls or other Karts), which can be very disorienting.
The suspension dictates heavily how the Kart feels. You generally want very hard suspension for classic Kart Racing experiencing. Though, you can tweak it however you like.
Suspension Locations dicatate where the suspensions should be cast from. You can also move these locations by their gizmos in the viewport.
Spring Length is the length of the line cast, ergo the spring.
Target Suspension Height sets the desired height, that the spring tries to reach. The spring can push, as well as pull the Kart.
When not in air, is directly responsible for keeping the Kart planted on the ground.
When jumping, the Kart cannot come of the ground because of this, so when jumping, the spring is briefly deactivated. The Suspension Reactivation Speed then says how fast the spring is reactivated, except when the Kart reaches below the Suspension Reactivation Height, then it the springs will get reactivated earlier.
Spring Force is the force multiplier of the spring, and Spring Dampening dampens the spring, so that it won't bounce up and down endlessly.
Clamp Spring Force is optional, but recommended depending on what your use case is. I was noticing when developing this Kart Pawn, that a high spring force is desirable, because it can react very quickly to the changes in terrain and jumping just works way better with a harder spring, especially when driving on hills.
However, when driving over small bumps, the spring would sometimes launch the Kart too high into the air, because the spring force would be too high. So the solution: Keep the high spring force and thus reactivity, but clamp the maximum force possible.
In the Example Project, you can add a long lasting test boost when pressing the upper face button of the gamepad, or by pressing E on the keyboard. It demonstrates the prepared Boost functionality that is implemented for easy usage.
The C++ class exposes a ready-to-use Set Boost function for Blueprints, such that a boost with a specific length (Decay Speed, how fast the boost disappears), New Max Speed and a Boost Acceleration can be applied.
When ticking Set Speed, the Kart will instantly receive the new Max Speed, otherwise it is only loosley enforced.
Ticking Reset Boost Progress will reset the Boost Decay Timer to 0.0 again when this function is called again. For example, imagine you activated a boost 5 seconds ago, and it is still lasting and has 1 second of boost left. Now the Kart activates another boost: Should the Kart now only boost for 1 second, because the timer is already ticking, or should the timer reset?
Resetting is probably what you want most of the time.
Ticking Async will use functions that should only be run in the async tick thread. You can leave this unticked except if you know what you are doing.