Here's a bit of info on how Criterion/Ghost's drifting works. Lots of technical stuff, so beware!
This was originally gonna be a response to u/LManD224's comment, but I figured I should probably just make it a post since it has a lot of info that others might wanna know:
Do you think you could make a loose summary of what DriftComponent does exactly? In the slides from Criterion's GDC talk about their approach to vehicles there's a bonus slide talking about how a "maintain speed force" is applied in the opposite direction of friction based on the cars angle to a "ideal drift angle" but the video of the talk doesn't go into this much further.
I've been putzing around with trying to make some "more arcade than simcade" (think like, I dunno, PGR or GRID 1) vehicle physics stuff in Unity and I've been specifically looking at approaches to drift assistance. The recent NFS stuff has been somewhat mixed as far as the quality of its results but given there's been a whole bunch of research/datamining on that front I figured it'd be worth looking at.
I was actually planning on making a tutorial series on how to replicate DriftComponent in UE4 eventually, so I can try to explain loosely how it works. Surprisingly I think I've been the only one really researching the handling in NFS games, at least in the modern era, so there's not a whole lot to go off of if I'm wrong about anything here.
So the "maintain speed force" is just the effect that everyone used to call the "drift speed boost" before Heat "removed" it (it wasn't really removed, they just lowered the param that controls its strength in every car's drift config, and they also increased a param that reduces the drift forward speed). That speed retention is based on a few things, and I'll try to explain it as best as I can. If you have Frosty and any Ghost game, you can open that up to check out any of the config params I mention in here. The first part of it grabs the vehicle's current speed and then checks to see if it's less than or equal to the maintained speed. If it is, it checks to make sure that all wheels are on the ground, then checks to see if the gas is being pressed, if the brake is not pressed, and if all the wheels have traction. If not it just sets the maintained drift speed to the current forward speed. I won't get too specific with the math here but right after that is when the Reduce_forward_speed_amount param, Max_speed_difference_for_maintain_speed param, and vehicle mass are factored into the equation. Then, the game takes the vehicle body transform and the front left wheel transform including steering (that part is important if your physical steering is separate from your visual steering), and does some vector math to get what I believe is the drift angle (the maintain speed function is the one I've looked the least into out of all the drifting stuff so I apologize for not being too detailed here). Afterwards, the rigid body's linear velocity is retrieved and there's some more vector math to calculate the speed retention, which is all finally multiplied by the Maintain_entry_speed_amountparam. Lastly, there's a little bit more vector math to calculate the final speed once the result from above is multiplied by the average ground normal, gas input, and tire grip before being multiplied by 60 and then they add the resulting force to the vehicle's rigid body.
The drift scale stuff is pretty straightforward at least from my understanding. For that it just seems to add simDeltaTime * driftScaleMul each frame, where driftScaleMul is just whatever drift scale multiplier from the drift config is chosen based on the current inputs (I believe multiple drift scale multipliers are used at once if multiple inputs are being used, but I might be wrong). When there are no inputs other than either the throttle or steering, then simDeltaTime * Drift_scale_decay is subtracted every frame. If you wanna see a somewhat simplified implementation of this and a few other things, I've been working on a custom DriftComponent plugin for NFS 2015 over here.
Drift yaw torque and side force are also covered in the project at that link, but I'll just cover them here anyway. Back in MW12 and Rivals (probably HP2010 as well but I haven't checked), donut yaw torque was also included in the drift yaw calculation but that has been moved over to the DonutComponent as of NFS15. Basically the game blends through the min, mid, and max yaw torque values based on the absolute drift scale. Then as the presenter in that GDC talk mentioned, they remap the steering input (not at the controller level, but just in relation to how your steering input interacts with the yaw torque) so that when you're not steering a lot of your drift angle can still be maintained. There's a bit more stuff that goes unused regarding blending down the yaw torque, before performing the final calculation where it all gets multiplied by the average surface grip factor, average tire grip, and the vehicle body's up vector. Finally, it's applied as torque to the vehicle body.
Side force is probably the most simple drift force out of them all. First it takes the current speed in MPH, and does an inverse lerp using that, Speed_for_no_sideforce, and Speed_for_maximum_side_force to calculate the side force speed ratio. Then the counter steering side magnitude is calculated which is (obviously) only applied when counter steering. This calculation once again uses the absolute drift scale, which is then multiplied by bodyAngularVel * 0.5 clamped from 0 to 1. The result of that is then multiplied by the Side_force_multiplier param, and then that gets multiplied by simDeltaTime * 2 and subtracted from the current counter steer side magnitude. Next up is the side force factor. This uses a couple ratios to determine the function output, one of them being the aforementioned side force speed ratio, and the other is a ratio based on the current absolute drift angle, Minimum_drift_angle_for_side_force, and Drift_angle_for_side_force. The end result is influenced by the average surface grip factor as well as the counter steer side magnitude and then clamped to a maximum of 5. The last part just takes all of that and does something similar to what the maintain speed force function near the end, except this force is multiplied by the left vector of course, and the main constant in this calculation to get the force is the Side_force_magnitude param. The last thing that's done regarding yaw torque and side force is to dampen those forces, because without that the resulting forces from these calculations are VERY big
Hopefully this was informative and you were able to learn a bit from it even though it's kinda all over the place and also obviously very simplified. There's more to the drifting than just that but I figured the rest of it should be pretty easy to figure out, while the drift forces are much more important to the feeling so it's probably more crucial info for anyone looking to make a system like this.
Posted Jan 26, 2021, 10:42 AM UTC · edited