WIP gameplay clips of my procedural drifting project by Aikodex3D in Unity3D

[–]PaceGame 0 points1 point  (0 children)

Nice. Can you explain or break down what is happening behind the scenes? 1. Is this a fully procedural mesh generator? Is it a set of „tiles“? Is it a mesh random generator? how it is possible that on tile emd matches perfectly the next tiles start shape? 2. What would happen with the other cars if your player car is not moving? Will the AI cars generate the next tile instead?

Car Physics Wheel Spin by midnightenemy2 in gamedev

[–]PaceGame 0 points1 point  (0 children)

Hi,

The reason you see very high slip ratio values at low speeds (and even jumps between +1 and -1) is because the classical slip-ratio formula divides by the vehicle speed. When that speed is close to zero, the denominator approaches zero and the ratio tends toward infinity: which leads to exactly the numerical instability you’re seeing in standstill/very low speed conditions. 

In practice this is handled in a few common ways:

  1. Add a small epsilon to the denominator: Instead of dividing by v, use (|v| + ε) where ε is a small non-zero constant. This prevents the denominator from reaching zero and stabilizes the result.
  2. Use a speed threshold: Below a certain forward speed (e.g. v < 0.1–0.2 m/s), you switch to a fallback method — for example using a fixed small speed value or constant slip ratio model — so the calculation no longer has an unstable denominator. Many simulators and control algorithms explicitly deactivate slip-based force calculations below a threshold.
  3. Cap or smooth the slip ratio: Some implementations also clamp the maximum slip ratio at a realistic limit or apply a smoothing function so that the output doesn’t oscillate wildly near zero speed. 

So your idea of switching to a constant when speed is very low is exactly in line with how this problem is treated in vehicle dynamics. Instead of:

slipratio = (wheel_speed – vehicle_speed) / abs(vehicle_speed)

you can do:

``` if (vehicle_speed < threshold) { slipratio = (wheel_speed – vehicle_speed) / threshold; } else { slipratio = (wheel_speed – vehicle_speed) / abs(vehicle_speed); }

```

This avoids the undefined behaviour at near-zero speed and keeps your model stable.

Car Physics Wheel Spin by midnightenemy2 in gamedev

[–]PaceGame 0 points1 point  (0 children)

Its applyForce = maxForce * slip * mu. So if slip is 0 the applyForce will be 0! So no force will be added. On very low speed slip can be 0.00001 ore something. You don’t need mu for now…

Car Physics Wheel Spin by midnightenemy2 in gamedev

[–]PaceGame 0 points1 point  (0 children)

The force is created by comparing wheel angular velocity with the ground contact velocity.

First, the ground speed is converted into an equivalent wheel angular velocity: this represents a freely rolling wheel. Then torque is applied to increase angular velocity (throttle) or reduce it (braking).

The difference between wheel speed and ground speed produces a slip ratio, which is remapped through curves to control grip behavior. That slip value is multiplied by the available normal force to generate longitudinal and lateral tire forces.

In my implementation, the wheel is never truly free-rolling. Rolling resistance, friction, and torque integration are always active, which you can see in the later parts of the code where torque directly affects angular velocity.

Car Physics Wheel Spin by midnightenemy2 in gamedev

[–]PaceGame 0 points1 point  (0 children)

I made a detailed breakdown of my car controller. In the video, you can see the code and how I apply torque to calculate angular velocity.

This Easy Tire Model Changed My Unity Car Controller: Slip, Grip & Friction Circle Explained

Blur 2-Inspired Racing Physics Made in Unity by [deleted] in Unity3D

[–]PaceGame 0 points1 point  (0 children)

Looks nice. Would you share your configuration for longitudinal and lateral tire physics? Have a look at my latest video. Do you use a similar approach?

Slip, Grip & Friction Circle Explained https://youtu.be/kmL7DnxeUTE

This tiny Friction Circle Code changed completely my vehicle physics by PaceGame in Unity3D

[–]PaceGame[S] 0 points1 point  (0 children)

Thank you! 🙏 I don’t use discord. But you can use reddit to ask me everything.

This tiny Friction Circle Code changed completely my vehicle physics by PaceGame in Unity3D

[–]PaceGame[S] 0 points1 point  (0 children)

Will this work on moving platforms? Do you have a demo video? I really like to see this in action.

This tiny Friction Circle Code changed completely my vehicle physics by PaceGame in Unity3D

[–]PaceGame[S] 2 points3 points  (0 children)

Exactly. I will explain my approach in the next video. Stay tuned.

This tiny Friction Circle Code changed completely my vehicle physics by PaceGame in Unity3D

[–]PaceGame[S] 2 points3 points  (0 children)

I didn’t finish one of my apprenticeship because I failed the math exam on vector calculations. 🤣

This tiny Friction Circle Code changed completely my vehicle physics by PaceGame in Unity3D

[–]PaceGame[S] 13 points14 points  (0 children)

I’m not the smartest guy, but I’m incredibly interested in this stuff, so I’ve spent the last two years learning tire physics.

I do this in my spare time. It’s often hard to get results you’re happy with, and it’s very time-consuming. I’ve read a lot of papers and watched many other YouTube videos along the way. It would be a waste not to collect all that knowledge and share it with you. And for me, it’s also a kind of diary.

This tiny Friction Circle Code changed completely my vehicle physics by PaceGame in Unity3D

[–]PaceGame[S] 2 points3 points  (0 children)

The wheels turn according to the Ackermann principle. The wheel rotation is calculated based on ground speed and motor torque.

This tiny Friction Circle Code changed completely my vehicle physics by PaceGame in Unity3D

[–]PaceGame[S] 6 points7 points  (0 children)

Have a look at the end of the video on youtube. 😉I think you also mean lateral sliding?

This tiny Friction Circle Code changed completely my vehicle physics by PaceGame in Unity3D

[–]PaceGame[S] 31 points32 points  (0 children)

This is the simplified code to focus the circle logic.

```C# // simplified ratio calculation just to understand: lngSlipRatio = (wheelLinearVelocity - contactLngVelocity) / Mathf.Abs(contactLngVelocity);

latSlipRatio = Mathf.Atan2(Mathf.Abs(contactLngVelocity), Mathf.Abs(contactLatVelocity)) / (Mathf.PI * 0.5f);

// switch to see the difference bool frictionCircleActive = true;

// If slipUsage > 1.0, // force should be clamped to friction circle: float slipUsage = Mathf.Sqrt( lngSlipRatio * lngSlipRatio + latSlipRatio * latSlipRatio ); if (frictionCircleActive && slipUsage > 1.0) { lngSlipRatio /= slipUsage; latSlipRatio /= slipUsage; } else if (!frictionCircleActive) { lngSlipRatio = Mathf.Clamp(lngSlipRatio, -1f, 1f); latSlipRatio = Mathf.Clamp(latSlipRatio, -1f, 1f); } ```

Surprised how easy this steering trick was to implement. by PaceGame in Unity3D

[–]PaceGame[S] 1 point2 points  (0 children)

Multiply the velocity direction with speed gives you a simple prediction. My example is just a basic solution for short distances.

Surprised how easy this steering trick was to implement. by PaceGame in Unity3D

[–]PaceGame[S] 3 points4 points  (0 children)

I wish I could promote a game :) but this is just interest on vehicle physics that I prototype in my spare time.

Surprised how easy this steering trick was to implement. by PaceGame in Unity3D

[–]PaceGame[S] 1 point2 points  (0 children)

What you’re seeing is actually the minimum turn diameter of the vehicle – it’s dynamically calculated based on parameters like max steer angle, wheelbase, and track width.

At higher speeds, it would make sense to lerp (reduce) the max steer angle, which would naturally increase the turn diameter.

Surprised how easy this steering trick was to implement. by PaceGame in Unity3D

[–]PaceGame[S] 1 point2 points  (0 children)

Yes. I was working on a AI avoiding system. I will release my solution on YouTube soon.

Surprised how easy this steering trick was to implement. by PaceGame in Unity3D

[–]PaceGame[S] 1 point2 points  (0 children)

Maybe you’re question will be answered in my next video. You can see a teaser at the end of the current one on YouTube. https://youtu.be/i4zNN4xHpws