[Music] my talk today is going to be about vehicle physics and tire dynamics my name is hamish young i'm i was the lead mechanic designer on just cause 4 and today we're going to talk a little bit about tires in particular on wheels but let's quickly just have a reminder of what just cause four is so just cause four is a big uh open world game open world action game uh we have a lot a wide range of vehicles uh over a hundred different types of vehicle um and a lot of them have wheels uh not all but a lot of them do and wheels and tires are really going to be the focus of this talk obviously we could talk about many different types of bits of physics but that's going to be the focus but some of these principles can be applied to other phenomena a little kind of note the code is deliberately hard to read because
it will take you time to read it uh if you want to read it through obviously get the notes afterwards um but i put it up there just as reference okay so one of the things we want to do is obviously set out what the goals what we're trying to achieve so we have some limitations we we've got a limited cpu budget we're making a big open world game and there's a lot of things going on tornadoes all sorts of things going on so we're going to have to you know keep performance pretty good uh alongside that uh we're running our sim at 30 hertz um and so we need to unlike a kind of dedicated driving game we're going to have a limited uh frame rate uh we want it to be believable uh now this is in quotes uh because obviously we don't want it to be actually realistic like a driving sim but we do want cars to kind of feel like they behave like cars and um and related to that is this idea of limited cognitive load
so when you're driving at high speed you want to be able to do other things and think about other things and not just driving and even when you have complex environments so that's one of the big design goals for what we were doing we also have a very wide range of vehicles small large and everything in between and we want one system that can cope with all those different types of vehicle and then obviously it's an open world we have a huge diverse uh environment to drive in and we want uh for the for that to work in all those environments so let's talk a little bit about the different kind of choices you can make in range of handling um you kind of got the kind of cart racing uh end which a lot of indie developers tend to have games kind of heading in this direction there's no tire model it's all just forces uh built on that kind of core rigid body um as you head through you know arcade
races and some extent there's a range where you might use a vehicle sdk from one of the physics providers and they have a kind of constraint based system and then you head into more sim card and driving simulations at the far end of driving simulations you end up with this really kind of accurate tire model with large complexity and what i'm going to talk about today is how to get here so how do you move either up this way or down the other way to hit the sweet spot that i'm going to be talking about so to give you a sense of the order of operations uh i'm going to talk about what we did for just cause uh we have gonna have similar input parameters to the simulation models so we're gonna take uh some elements from the simulation but we want much higher grip than is real uh for that kind of uh use of arcade kind of physics
we're going to i'm going to talk quite a bit about friction clamps to stay physically stable and this is kind of similar to how the constraints based driving models work and then i'm going to talk about how you can draw friction curves uh and then scale down the pitch and roll components to compensate for the grip and then we can talk about the driver assist stuff which is actually very similar to the kart racing kind of physics you might see at that end so what we're really trying to do is bring all those elements together into something that works as a whole so let's talk a little bit about the kind of semi-empirical forza gran turismo end of things um the models actually take real tight you take a real tire and you put it in a real machine and you vary the input parameters and you measure the outcome and then you curve fit that outcome to replicate it in your game and the more accurately you can do that and the
higher frequency you can run that at the more accurate you're going to be the downside is that if you want to modify what those tyres do you don't want real it gets pretty hard to modify and there are real reasons why you may not want real tires for a start if you want to run at 30 hertz well you're going to get terrible feedback especially when you have weight transfer uh you're not going to feel it and the car is just going to be um unpredictable in its behavior you also i mean anyone who's gone from an arcade game to tour to a driving simulator is understeer is a big deal if you break and you understand you don't hit the corner it's kind of unacceptable in open world game i need to come up to a t-junction and get around that corner and oversteer can be an issue but actually it's not such a big issue um but if you do want to kind of correct oversteer in a very physical correct way you need complex
traction control and stability control and that's difficult to get right so i'm going to talk a little bit about the tire setup um there are some basic parameters we're going to need to assume we've generated the wheel has a position an orientation which includes the steer you've got a linear velocity of the wheel and then you've got its angular velocity in the direction of the spin and then you've got some sort of ground position and normal where the tire is hitting the ground so this is the the tyre reference frame i'm going to be talking about and we're splitting the velocity into things that go along the line of the wheel with things that going lateral to the wheel and then you've got the angular velocity of the wheels spin so slip ratio this is one of the input parameters that we're going to be using and i'm going to take you through the kind of different phases of it so wheel spin is defined in the slip ratios when the wheel is spinning faster
than it's moving forward there's a kind of intuitive thing here where the point on the rim that's going round if it's if it's perfectly gripping then you actually end up with zero so you're following the road so wheel spin is when it's going faster than the road and then when you're locked the wheel is completely locked and you're sliding forwards and that's negative and the reason why we are in this space is because when you're breaking your your in this negative value up to -1 and that means you get a you know get a breaking force and if you've got a positive direction then you're going to have acceleration and it's going to be a positive force and this slip ratio is now defined between -1 when you're fully locked and up to essentially infinity positive infinity when the wheel is stationary but spinning fast so if you like mathematics uh this is
the equation you'll see in books um which is literally the what i've just shown you there um and there's a little bit of code which is pretty hard to read which does the same thing but in the game engine actually it's a little bit more complicated there's a little bit of a gotcha here if i actually go back what happens is if the wheel spin is positive and you're going backwards so it's negative uh you actually get a minus sign on this first uh piece you actually end up something that's kind of more negative than minus one that's something you don't want um so in reality you want to make a modification we've got a little bit of a more complicated bit of code here which you can potentially look at later just to cope with those edge cases and those edge cases are things that you might want to try and avoid okay let's talk about slip angle so slip angle is literally an angle um and it is the angle where the direction of
the wheel is essentially sliding um it's it's just basically as simple as that so all you're working out is what that angle is in the two directions of the wheel velocity and you know it's a pretty simple piece of code we also have camber so this is how much the wheel is rolling over relative to the relative to the ground and uh once again it's a relatively simple equation and this is a kind of a core piece of understanding uh how the wheel is relating to the ground patch and finally you have wheel load now in a sim uh case the suspension is very high frequency you're going to get a lot of detail in how that wheel load works and the thai model is going to kind of react to that in a very dynamic way a 30 hertz that's not really very possible to get of great results out of and also you basically don't want too
much weight transfer so to keep everything kind of realistic what actually happens is the suspension force at rest when the thing isn't moving you can blend that in to the suspension force with the dynamics and you can end it up some with something that's scaled right and can give you a wheel load that's kind of reliable so if you want more grip we have an issue the grip can cause things to diverge so if i've got a velocity of a wheel and i put it through my tire model and i end up with a big force i'm going to end up with something that actually ends up going the wrong way and even faster than the way it started which means a bigger force which means it starts going the other way you get the model can diverge um and so the drag from the grip uh is flipping the sign of velocity is something you should never want it's actually one of the reasons why these things can be unstable
so we're going to introduce this idea of a friction clamp the friction clamp is a way of essentially enforcing the fact that the friction is only going to behave like a friction it's not going to uh go wrong and actually this principle is used all over the place so for aerodynamics when you have a a v squared term and it's unbounded having a friction clamp to prevent it from firing your thing backwards when you're going too fast is a pretty good thing to have the danger here is that the mass in this equation so the uh the kind of a applicable mass you're trying to use uh if you have more than one tyre which is pretty much every vehicle you can't apply all to the same mass and so it's a little bit more complicated but in a solver so in a in an iterative solver like the log of the physics engines this is essentially how they're doing their vehicle physics they're taking the clamp and they're scaling down how much force you're going
to get out relative to that clamp which keeps it always in the middle but it it has a downside in terms of if you wanted any effects based on wheel spin like losing grip because of wheel spin it doesn't model that at all so instead of doing that what we're talking about is actually actually providing the friction clamping code but introducing this idea of useful mass so it goes back to this idea of wheel load so if you have all of the wheels with the correct load and everything is stationary then the relative mass that's going to be uh relative to that wheel is the heuristic is that you end up with this wheel load divided by all those uh wheel loads and that kind of gives you the ratio of the vehicle mess you should be representing by that one tires friction clamp now it's not completely perfect but it's a pretty good heuristic and it works very very well up to tiny tiny velocities and
it's what i'm going to be using for the rest of the talk okay so longitudinal friction clamps so the different dimensions in which we need these clamps the first one is the wheel sliding forwards and we just want to prevent it from going back on itself in a completely linear sense so uh we have this useful mass and we're trying to prevent the the the forward force from being bigger than to require to stop that wheel um the only complication here is the wheel is actually putting power in if it's if it's got torque so you you want to take that into account as well and that's what the second term here is for the angular clamp you're trying to prevent the wheel spinning the wrong way and changing the sign of the slip um and so your reaction force needs to not be too big itself and that's a little bit more complicated you're ending up trying to work out what the new velocity needs to be relative to the slip and so the code is a little bit more complicated but it ends up generating what the
maximum force should be to prevent the wheel actually spinning the wrong way relative to the road speed and the third thing is this lateral clamp and likewise you might think that was simple um but it's just the mass you know going sideways but you've got to worry about um the angular considerations and theoretically longitudinal clamps should do the same thing i'm not going to get you to read this code but essentially it's taking into account the inertia and not just the linear uh force so once your programmer has sorted out the friction clamps uh let's let's take a look at what what it does so this is with the friction clamp on um the car's gonna accelerate you may see the curves uh and you can see that the the markers on the curves are smooth and they're not jumping around and there's no uh jitter whereas if i show you with the clamp off you should be able to see that the the actual markers as the the car drives away the car is shaking
and so is the the values they're jittering all over the place because they're not getting clamped you're getting this divergence obviously you don't want this in your in your game so once you've got your clamps in place now you can turn up the friction as much as you like because you're never going to break it your designers can go absolutely wild they can do whatever they like but if you really want to set things up in a way that is controllable in a without having to record real tie data you really want to be able to find the right friction curves for your for your game so we actually literally draw the friction curves in the spline tool as as you can see and we have a like a three-phase model so any of the curves you end up with zero relative to a peak and then you saturate out at the far end um and the reason why we do this so the curve can have as many points as you
like the difficulty is that um for the working out what the uh the curves in each direction need to do in a more complicated model you end up with these complicated mathematical relationships between these these uh different parameters and we're trying to simplify that down to something that ends up being only a few graphs so this is possibly the difficult most difficult part of the talk but essentially if you're talking about the force of which you're going forwards so this is about forward force here if you are not slipping sideways at all then when you accelerate you're going to get a certain curve and when you break you're going to get a certain curve but when you're sliding sideways and you want to go forwards you may get more wheel spins so you you want to you're reducing the the kind of the shape of the curve um and it's something that lets you have things like doughnuting so if you want to donut
then you want the side slip to actually let you wheel spin and likewise the other way around so now you're thinking about lateral force so these curves are the force relative to the slip angle um you're going to have five of them for each of the slips of the wheels so this is how you can get uh effects like drifting naturally where if you um slam the handbrake on this bottom graph kicks in because you're getting a a negative slip angle that's going to mean you have low lateral grip so you're going to slide sideways and then you're going to pump the accelerator so now you're in the saturated you know unsaturated slip angle and you're you're you're getting that wheel spin which then gives you low uh low lateral force as well so the bottom graph and the top graph skip all the middle middle ground and you you get that change of behavior so the relationship between the lateral graphs and the longitudinal graphs
is something that can be a little counter-intuitive but it's still simpler than trying to modify a complicated mathematical function like you would have for a magic formula tyre it takes a little while to get your head around but actually it's very powerful once once you get your head around it and it's really this that is the basis of the model so if you uh head back between here you really want to understand that the the the angle uh that you have uh and the steepness of the curve kind of represents the feel in in a different way than you might expect so the steepness of the curve is really how much grip you feel it's not the it's not the actual height it's the steepness that matters and as you go up the curve you're going to have feel it's grippy and as it levels off you're going to feel like actually it's sliding and if it drops it actually feels like the slide is getting faster and so as you're going gain intuition
about what these curves feel like you can really begin to play with when you get wheel spin how does the car feel when it's turning when you uh when you're drifting how does it feel and you can balance this out now in our engine all of these curves were normalized so actually in the final game we only had pretty much two or three sets of tires for the whole all vehicles in the whole game um because they basically did the right things and it meant that we only had to set up the actual uh grip value themselves so i'm going to move on to that in a second the actual grip uh which was authored front for the front and rear wheels was just essentially a value and we were trying to balance the front and rear grip and that was multiplied by this graph this set of graphs that i mentioned earlier obviously multiplied by the wheel load so it's scaled correctly uh and then we multiplied the time step to get the impulse um it once you got to basically a grip
level multiplied by this graph multiplied by the wheel load multiplied by the time step you really have quite a simple equation of these forces but and here's a big thing if you want something to be believable and you turn the grip up all that's going to happen is your car is suddenly going to wallow and roll and do horrible things now you can add kind of anti-damp like suspension and stiffen the suspension all those things but if you want those values to be vaguely realistic you're actually the best thing to do is to modify how you're going to apply the force to begin with so if you reduce the pitch and roll components of the forces you were going to apply to the wheel you can really turn this down in a very controllable way you don't have to redo your suspension setup so in this case we just decompose the impulse of the point back into the linear angular components and then we we just multiply by linear factor into the roll and pitch and that and that just made it so the
suspension setup could be completely kind of realistic and the extra grip didn't cause too many problems okay so just as a as a high level summary so we've got some input parameters we've got slip ratio and slip angle um we're turning the grip up higher than real and we're preventing it from getting too big with the friction clamps and so that element of the friction clamps is is keeping us physically stable whatever graph i draw uh and then we can draw friction uh friction curves and actually you have tremendous amount of freedom here so once you've got the clamp in place you have a lot of freedom and for our planes and non-cars we actually just had a linear ramp and a and a saturation and we didn't have this complicated uh wheel spin effect because the clamps meant that whatever happened we would stay physically believable and it would be fine if you then have
too much group you can scale down the pitch and roll components and then you get to the final step which is uh like driver assist drift control and that actually goes back to that kind of cart racer type physics you're really controlling the car from the basis of a rigid body and the forces and there are many many ways of doing this and it really is a talk in its own right and i'm not going to dive too deep into it although if people have questions obviously uh that's important um but the real thing is if you come from that kind of cart racer feel actually you'll be very familiar with the kinds of forces you might want to do here the way that we triggered drift is either by obviously button press and and control but you can also trigger it by um if the slip angle of the rear wheels gets beyond a limit you can then get into that kind of drift phase and you start controlling the vehicle at the whole vehicle stage and not about the tires so in our model we've actually ended up
using all parts of the spectrum of that kind of cart racer handling for drift the kind of physics sdk style friction clamp model for keeping us inbound and then a slightly semi-realistic tire model modified uh in the heading off in the more sim direction and all these things come together means that we can run at 30 hertz you can go around a corner very fast unrealistically fast you can control in the drift and you can really bring these things together and so the the kind of final point i'd like to make uh before i would kind of go off this topic is that the people who are building indie games with uh the kind of cart racer mechanics if you want to go a bit more physical and you want to add tires the next step along that path would be to get your friction clamps right for the
wheels and then you can do whatever you like with your tire model it isn't that hard to move from one to the other so that's my talk thank you very much any questions hello hi thank you for the talk my question is how did you decide where to place the tires on the ground and how did that interact with your calculation of suspension forces sure uh so the question was uh how do we decide where to put the tyres on the ground and how does that interact interact with suspension forces uh so we did line tests uh to place the wheel on the ground um and then the suspension force held the vehicle off off the uh off the ground um it's very similar to like lots of simplistic
behaviors the line tests were linear so we weren't doing anything sophisticated like if you wanted to model more sophisticated suspension geometry you would actually put it on a on a circle to change how the raw center worked but we kept it very simple just had line tests so that's how we placed the wheel uh quick follow-up then if debris flew under your line test what would you do if debris fell onto the line test yeah would that push the car up uh it depended so uh we have a physics model where you have layers um and so the collision with a raycast depends on whether something was tagged to be in the layer or not um so in the case of debris it depended on which layer that debris was if it was big enough then yes absolutely it would it would climb up on it but we could for very small things we could not put them in that physics layer and so they'd be ignored by the line test okay thank you okay anybody else
hey i was uh wondering i thought that just cause went through the havoc engine once you've done the calculations for the forces due to the tyres how did you integrate that back into havoc or did you have your own solver so uh we can uh we used havoc to uh there's an api and havoc to apply forces so once we calculated what force we wanted to apply we applied it the solve happened in in the havoc solver thanks hey yeah kind of related to the first question uh since you did line test down you said i was just curious because i've hit this problem do you have any issues with like going over a curb and having you know it immediately changes uh you know in all that the suspension and i pretty much have things where cars fly when i hit curves did you do anything to address that or did you even have that issue yeah so the question is about um line tests and the compression of a wheel
based on a time step and finding a surface that that wasn't there before right exactly yeah yeah i figured you'd get it and you can rephrase it yeah yeah um so uh so there's two issues here so one is being loads uh uh kind of insensitive we didn't get side forces based on that right so the only issue is the suspension force itself um so we didn't suddenly gain grip just because we we hit the hit a curb um essentially the idea is you're gonna have to damp uh those those those forces um uh and there are multiple ways of doing that um we we took a pretty basic approach to that um and you can tell when you've moved the suspension a long way in one frame that you you need to damp so gotcha right thanks cool okay thanks very much
Auto-generated captions from YouTube — names and numbers may be misheard.
Game Developers Conference · 2026
Game Developers Conference · 2026
Game Developers Conference · 2023
Comments