Hi all!

I'm working on integrating BEPU in my game engine. It's works great. Also I have a vehicle driving around, which also works great so far but now I'm a bit puzzled and require some pointers.

I have a vehicle set up that drives pretty well. Now for visual appeal I want to fake wheel spin, like doing a burnout, and add tire smoke when the wheels lose grip. Now I know I need to adapt BEPU code for this, probably in WheelDrivingMotor and WheelSpape classes.

So my question: So BEPU calculates the power from the floor to the wheel to the car, but how do I get the remainder, e.g. the power left that was not transferred to the car?? My reasoning behind this is, that when I get this value, I can calculate (or determine) that the wheel is spinning faster than the car is moving, thus generating 'smoke'. Same goes for sliding.

Can you give me some pointers on where to look, and which variables are important?

Thanks in advance,

Michiel

## Vehicle wheel friction

### Re: Vehicle wheel friction

The WheelShape.UpdateSpin function is responsible for heuristically updating the spin. You could change that if you'd like, but it's useful to note that the wheel's spin has no relevance to the simulation, so you could just as easily ignore the in-engine transform and rebuild your own transform externally from the same building blocks (Wheel.DrivingMotor.RelativeVelocity and so on).

One important note- the vehicle wheel constraints never bother with actually modeling a wheel. Instead, the constraints all work on linear impulses. So it's all linear velocities and forces instead of angular velocities and torques. This also means that there is no power 'remainder' as far as the simulation is aware- there is only a target velocity and a maximum force that can be used to work toward that target velocity. Things like spinning wheels due to excess torque are just totally arbitrary choices as far as the transform goes; the simulation has no principled suggestions.

Horizontal sliding is a little more direct- Wheel.SlidingFriction.RelativeVelocity gives you the velocity along the axis perpendicular to rolling. Large values there would imply the car is sliding out of control and some squealing might be in order.

Notably, building a car out of multiple rigid bodies and connecting them with constraints (e.g. SuspensionCarDemo and friends) would allow you to have 'true' simulated spinouts automatically. Such a constraint vehicle would just tend to be a little more expensive and possibly less stable at extreme speeds. Also, this still wouldn't be a great model for a realistic vehicle- tires are not exactly rigid bodies, and the friction approximation is questionable.

One important note- the vehicle wheel constraints never bother with actually modeling a wheel. Instead, the constraints all work on linear impulses. So it's all linear velocities and forces instead of angular velocities and torques. This also means that there is no power 'remainder' as far as the simulation is aware- there is only a target velocity and a maximum force that can be used to work toward that target velocity. Things like spinning wheels due to excess torque are just totally arbitrary choices as far as the transform goes; the simulation has no principled suggestions.

Horizontal sliding is a little more direct- Wheel.SlidingFriction.RelativeVelocity gives you the velocity along the axis perpendicular to rolling. Large values there would imply the car is sliding out of control and some squealing might be in order.

Notably, building a car out of multiple rigid bodies and connecting them with constraints (e.g. SuspensionCarDemo and friends) would allow you to have 'true' simulated spinouts automatically. Such a constraint vehicle would just tend to be a little more expensive and possibly less stable at extreme speeds. Also, this still wouldn't be a great model for a realistic vehicle- tires are not exactly rigid bodies, and the friction approximation is questionable.

### Re: Vehicle wheel friction

Thanks for your answer.

For the wheel spin its not a problem to model this myself. Without the power remainder I would need to fake this all together. Not really a problem for now, as I can spin the wheels and rev the cars engine when applying power. I'll try and fiddle around with this.

For the Wheel.SlidingFriction I added a new property called RelativeSlidingSpeed which is set in the PreStep of the WheelSlidingFriction, that gives the relative sliding speed. This works pretty solid. Added code for reference.

For the wheel spin its not a problem to model this myself. Without the power remainder I would need to fake this all together. Not really a problem for now, as I can spin the wheels and rev the cars engine when applying power. I'll try and fiddle around with this.

For the Wheel.SlidingFriction I added a new property called RelativeSlidingSpeed which is set in the PreStep of the WheelSlidingFriction, that gives the relative sliding speed. This works pretty solid. Added code for reference.

Code: Select all

```
if (Math.Abs(RelativeVelocity) < staticFrictionVelocityThreshold)
{
blendedCoefficient = frictionBlender(staticCoefficient, wheel.supportMaterial.staticFriction, false, wheel);
relativeSlidingSpeed = 0.0f; // Wheel is not sliding
}
else
{
blendedCoefficient = frictionBlender(kineticCoefficient, wheel.supportMaterial.kineticFriction, true, wheel);
relativeSlidingSpeed = Math.Abs(RelativeVelocity) - staticFrictionVelocityThreshold; // Wheel is sliding, set relativeSlidingSpeed
}
```

### Who is online

Users browsing this forum: No registered users and 2 guests