VehicleBody3D randomly losing all speed at landing

Hi,
I’m using a customised VehicleBody3D object, but I don’t feel like any of the change I’ve made should create this behaviour : Some times, it’s fairly rare, but not enough so I could ignore it, when landing after a jump, my car will brutally lose all its speed. To clarify, the car is not reaching any super crazy speed or height, it’s more tame than a NFS game for example.
I’ve tried to change the suspension max force to absurd level, I’ve tried limiting the fall speed, I’ve tried changing some physics settings like doubling the physics ticks per seconds, using or not Continuous Collisions…
Nothing worked.
I’m using this method to generate my road : https://www.youtube.com/watch?v=4nOEVPjVmjc&list=WL&index=2&t=1s

The documentation says you should avoid CSG shapes for some reason, so I tried exporting my mesh, cleaning it in Blender and reimporting it and generating a Trimesh collision shape, but it didn’t fixed anything.

One weird thing I found is while trying to limit my fall speed, I used this line of code :
linear_velocity.y = clampf(linear_velocity.y, -25, 100)
And it worked, but the strange thing is that if I use this specific minimum value (-25), when I run my game, my car starts at like 20 meters in the air (for some unrelated reasons). It falls, it reaches the ground and then… it clips trough the ground.
But only if I use -25, if I type -24 or -26, it works fine.
So I guess the fall speed of -25 is the perfect value for the car to reach the ground just between 2 physics ticks, which seems like a crazy coincidence.

So I’m not sure if this is related to my problem, maybe if the landing happen just at the wrong time between 2 ticks, it messes the physics.
But again setting the game at 120 ticks per second didn’t fixed it (I’m not even sure it’s happening less). I could maybe set it at 500 ticks per seconds or higher, but I’m not even sure it will fix anything, and I feel this is the worst solution possible to this problem.

Anyone has an idea ?

It’s hard to help you with your problem when you don’t include what make’s your VehicleBody3D object “customized”. How is it different from the out-of-the-box VehicleBody3D?

I might also add a quote from Godot’s documentation which states:

Have you tried applying a physics material with 0 friction to your VehicleBody3D?


More information about your project would be appreciated:

  • Relevant scripts
  • Vehicle scene configuration
  • Run-time example of the abrupt speed loss described (video or images)
  • etc…
1 Like

It’s hard to help you with your problem when you don’t include what make’s your VehicleBody3D object “customized”. How is it different from the out-of-the-box VehicleBody3D?

Not different in any way relevant to this problem, I’ve added things like changing gears or drifting (which is disabled as soon as the car leave the ground).

I might also add a quote from Godot’s documentation which states:

Yeah, but I don’t feel like this issue is outside of what I could reasonably expect from this class out of the box. I’m making a very classical and straightforward racing game, and it’s working fine 99.99% of the time

Have you tried applying a physics material with 0 friction to your VehicleBody3D?

This is interesting.
I’ve tried it, and now even without jumping, when I reach the bottom of a slope, I lose a good chunk of my speed. Again, it doesn’t happen all the time, but I feel like this is more common than my previous problem.
And the other problem is still there.

Run-time example of the abrupt speed loss described (video or images)

There you go, I was “lucky” enough to have both bugs back to back :

But I do think the loss of speed was even worse before the friction change.

Ok, I THINK I might have fixed it.

It SEEMS the issue was that sometimes my car hitbox was hitting the ground instead of the wheels. I think it was amplified because I’ve made wheels a bit too small on my car (and now I’m too lazy to change the model).
Anyway, here a picture of the previous hitbox (in red) and the new one) in blue :

It makes some collisions a bit wonky, but it’s not game breaking and it works with the kind of retro aesthetic I’m after.

I also put my friction at 0.3. I’m not sure this is changing anything related to this problem, but I prefer my car to not lose too much speed when hitting a wall.

I’m not 100% sure the problem is fixed, but I think with the amount of testing I’ve made after the change, I would have encountered the bug at least once.

I will keep this open for like a week, and if don’t see it happen again, I will mark this as solved.