Physics2D - Car won't go fast but falls fast. Checked drag, motor is overpowered.

Hello there,

I’m having a problem with my game, I have a car and it’s working okay, but there’s no way it’s going past certain speed. I think it’s because of an angular velocity limit on the wheels but I’m not sure also. I’ve checked the drag on all parts (all 0, both linear and angular) and the motor IS powerful enough. The car simply refuses to go faster. :(. The maximum speed it reaches is about 33, what’s too slow for my game, but when falling, it reaches like 101, what is fast enough, so, I don’t think it’s a drag issue, it has some hardcoded drag or linear speed limit because it won’t go faster than 101, but that shouldn’t keep the car from accelerating to that speed afaik. I’ve tried playing with velocity and position iterations, no luck. Even when applying force directly to the car body so it goes faster than 33, when I stop applying it it decelerates quickly to 33, what doesn’t make sense because damping is 0. So, it’s another clue that the problem is a hardcoded maximum angular speed acting on the wheels.

Any ideas on how to solve this issue? If it’s a problem with unity code, perhaps I can access the box2d implementation code and fix it?

Thanks in advance.

I was never able to get the 2d physics system to properly accelerate my vehicle using wheel torque so I switched to adding force to the body. If I have time today, I’ll record a video of how I put together my car for your reference.

Thank you man, as I mentioned above, adding force directly to the car works, but besides that it feels weird (suspension doesn’t seem right) the wheels will decelerate it to that 33 speed when you stop applying force to it. It’s not a good approach imho, 2d physics engines works generally wonderfully by using real wheels (and possibly ccd), so that’s the proper way imho.

One thing I can suggest checking before I get off here for the day is to make sure your wheel colliders are not colliding with the car body. You can put the body on 1 layer, the wheels on another and disable collisions between the two layers via Edit > Project Settings > Physics 2D (Layer Collision Matrix).

Thanks for the suggestion, but they aren’t colliding. Another thing that popped in my mind is the scale of the scene, as that should affect the physics also, unfortunately there’s no ‘world scale’ setting or something similar that I’m aware of, so, I’m going to have to re-scale the entire scene, what’s quite tedious considering that masses and forces (e.g suspension springs) will get messed. But that’s worth trying imho. Box2d in Unity really needs some more work though.

Nope, scaling the thing to 0.3x didn’t work also. Now it sticks to the speed of 9.

Hello there.
I’m attaching two test scenes:

base_scale.unity is the scene at a reasonable scale (default cubes and spheres)
max.speed when falling: 100
max.speed when using motor: 46.84 (49.9 when increasing max.force on the fly)
max.speed by inertia: 39.07

ten_percent.unity: it’s the scene scaled to 0.1x
max.speed when falling: 100
max.speed when using motor: 11.8
max.speed by inertia: 3.73

I just want my vehicle to go fast in a way that at least looks like it’s going fast, let’s say, 30 for the smaller scale scene and I don’t want it to brake so quickly when it stops accelerating.

I’m not a fan of ‘ugly workarounds’, for example, getting and setting the speed each frame and stuff like that, also, as I’m planning to add a quite complex suspension system I would like the wheels to accelerate the vehicle, not apply force to the chassis (too hard to simulate friction and ‘loose’ ground this way).

If anyone manage to make the vehicle in the ten_percent.unity scene accelerate to a reasonable speed and don’t brake quickly when stops accelerating I’ll be eternally grateful. :slight_smile:

Thank you in advance.

1461875–79786–$GoFaster.zip (116 KB)


EDIT:

After playing a lot with the thing, I’ve figured that the problem is there’s a hard limit for the angular speed of the wheels (4500). I wonder if there’s some way to change that.

Just to update: I reported the bug and the devs they confirmed the issue, it seems to be a hardcoded angular velocity limit indeed. I hope they fix it soon or at least increase the limit to a more practical level, at the moment it’s impossible to make any racing game with that limit. (with wheel traction)