Jump to content
  • Advertisement
Sign in to follow this  
NDraskovic

Increasing vehicle realism when turning

This topic is 382 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys,

We are working on a project that revolves around driving different types of vehicles. We have already created a basic driving mechanism that works very well, but one of the problems we are having is that the vehicles are obviously rotating around their middle (or more precisely, around their center of mass) which doesn't look too realistic. Moving the center of mass towards the front of the vehicle gave a bit better result, but it makes the vehicles more unstable on frontal collisions  and bouncing when encountering terrain unevenness.

Our goal is to have the front wheels turn first and "pull" the rest of the car behind them.

We are not using wheel colliders, rather one rigidbody (attached to the body of the car) to which we add forces and torque.

The code itself is pretty simple, it calculates the turn vector with regards to car mass, user input and some other parameters that we added to each vehicle to differentiate them, and then add torque to the car rigidbody with regards to that vector.

My question is, have you encountered this problem, and what would be your suggestion on solving it?

Thanks

Share this post


Link to post
Share on other sites
Advertisement

Have you tried changing where you apply the force to the rigid body?  If your turning force is applied towards the front of the vehicle, you might get the results you like without changing the center of mass.

https://docs.unity3d.com/ScriptReference/Rigidbody.AddForceAtPosition.html

Another option might be to have two rigid bodies that are connected, and add the torque to the rigid body that is the front.

Edited by ferrous

Share this post


Link to post
Share on other sites

How realistic do you want to go? In a typical sim, you'd apply 4 forces at the 4 wheel locations, and because these locations are offset from the centre of mass, this also creates 4 torques. 

Share this post


Link to post
Share on other sites
18 hours ago, ferrous said:

Have you tried changing where you apply the force to the rigid body?  If your turning force is applied towards the front of the vehicle, you might get the results you like without changing the center of mass.

I'm using AddTorque to turn the car, and that function does not have a positional option (torque is applied around the provided axis). I'll try switching to AddForceAtPosition, and see what happens. 

 

13 hours ago, Hodgman said:

How realistic do you want to go? In a typical sim, you'd apply 4 forces at the 4 wheel locations, and because these locations are offset from the centre of mass, this also creates 4 torques. 

This part is a bit tricky to explain - we would like the driving itself to be as realistic as possible (obviously, we are making a game, not a simulation, so some concessions will be made to speed the development up), however our vehicles have the ability to "fly" (not like airplanes, but they need unrealistic maneuvering capabilities when airborne), so the behavior of the vehicle differs when grounded and airborne. 

We have mechanism in place that determine if the car is grounded or not, but they are not perfect (for instance how to differentiate between the flight we want to control, and a simple bump on the road), so that causes some problems. 

I've tried switching from one "main" rigidbody to main+4 wheel rigidbodies, but it causes the vehicle to go crazy on every little bump (it gets too shaky, and very hard to stabilize, even with anti roll code implemented).

The most obvious problem that I want to solve with this is the following scenario:

- if the vehicle is close to the wall or any other type of fixed obstacle and I try to turn to the opposite side, the back of the car moves towards the wall and causes a collision that pushes the vehicle back to the wall. In reality, the front wheels would pull the car, without the back of the car going the opposite way

Do you have any suggestion that might help me with that problem?

Thanks for your input

Edited by NDraskovic
Added information

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!