Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411512 Posts in 69376 Topics- by 58430 Members - Latest Member: Jesse Webb

April 26, 2024, 09:26:27 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 3755 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
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic