Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1410961 Posts in 69598 Topics- by 58584 Members - Latest Member: spaghettisoftware

October 14, 2024, 06:40:59 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Ideas for a car braking system using a physics engine
Pages: [1]
Print
Author Topic: Ideas for a car braking system using a physics engine  (Read 5163 times)
giovz481
Level 0
**


View Profile
« on: June 30, 2023, 03:52:16 AM »

Hi all!

I'm developing a car racing game, with 2D physics, using the library Box2d. I'm trying to implement a realistic car brake. For this purpose I used a FrictionJoint between the wheel and its pivot point (which also works as a suspension). When I apply the brakes, this joint applies friction, which tends to equalize the rotation between the wheel and the pivot point (which cannot rotate, so the wheel tends to stop). That's the behavior I was expecting, but sometimes it shows like an oscillating behavior, mainly when the wheel is almost stopping. It kind of go forward and backward, oscillating, which is not a realistic behavior for a braking system. Anyone maybe have already had a similar problem? Or have an idea why this happens and how can I solve this? Or any different idea I can implement this brake system for an individual wheel, using joints or something like this? I said I'm using Box2d, but I think ideas used in other physics libraries can also help here. Thanks in advance!
Logged

michaelplzno
Level 10
*****



View Profile WWW
« Reply #1 on: July 01, 2023, 12:28:29 AM »

If I were doing this I would just apply friction to the car's body as the breaking force rather than locking the wheels.

Another idea is that cars don't lock their wheels when you break, they just apply friction to the wheels that reduces their rotation over time. If you were to instantly lock the wheels at a high velocity a car would fall apart.
Logged

Menwyr
Level 0
*


View Profile
« Reply #2 on: October 29, 2023, 06:03:15 AM »

I highly recommend reading anything on technical-mechanics and physics if you haven't done so. Simulating something like what you have described is relatively straight forward, even with the way you have done it. Oscillations are part of everything, in real life engineers do their best to either get rid of the source or use... friction. Is the stopping simulation only cosmetic or are there rigid-bodies involved i.e. is anything bumping into the breaking car gameplay wise?
Logged
DANDAN1
Level 0
*


View Profile WWW
« Reply #3 on: May 27, 2024, 04:47:33 AM »

It sounds like the oscillation issue you're experiencing with the FrictionJoint is due to the nature of how friction forces are applied and dampened in Box2d. This can sometimes cause instability or oscillations, especially when the wheel is nearly stopped.

you can tru to increase the damping properties of the joint to reduce oscillations. This can be done by tweaking the damping ratio in the joint settings. This will help smooth out the oscillations as the wheel slows down.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic