Page 1 of 1
Vehicles - Constantly Slow Down While Turning?
Posted: Wed Jan 04, 2012 3:59 am
by Astrimedes
Is anyone else experiencing an issue where when a vehicle is both turning and accelerating at the same time, the vehicle slows at a constant rate? I've tried modifying a lot of the vehicle's settings, but this issue seems pretty consistent. If I start driving the vehicle in a circle, with steering turned to maximum in one direction and the accelerator held down, it will just constantly lose speed until it comes to a stop. It seems as if the (relative) horizontal velocity is being killed entirely, instead of redirected, so the vehicle just constantly slows down if you are turning sharply. I experience this issue seemingly independent of motor settings, suspension settings, car sizes, masses, etc. but I am definitely no expert, so I would be overjoyed to hear any suggestions of which objects to fiddle with.
Just finding out if anyone else has seen this phenomenon would be helpful. And, maybe someone could provide me with pointers on modifying the WheelSlidingFriction (or any other relevant object!) in order to counteract this? I'm not above doing something really hacky to augment the "forward" force while turning

Re: Vehicles - Constantly Slow Down While Turning?
Posted: Wed Jan 04, 2012 4:22 am
by Norbo
If the steering angle is particularly sharp, friction will remove a lot of forward momentum. This can become even more of an issue if the steered wheels are not also the drive wheels. Imagine turning the front wheels 90 degrees and then using the back wheels to try to move; all of the drive force would be fought by the front wheel friction. If the front wheels were both the steered wheels and drive wheels, then the car would at least turn (though it still won't turn as smoothly as a regular car that doesn't have super-sharp steering angles).
Another possibility: are there a bunch of wheels capable of interfering with each other? Some might turn, but the rest may resist the motion. This is typically noticeable on any vehicle with more than 4 wheels (or just some wheels in odd places) unless measures are taken to counteract it.
The VehicleInput in the BEPUphysicsDemos shows one way to set up the vehicle. It might be a good idea to start by fiddling with that incrementally to reach the desired behavior if the car you're dealing with is a standard 4 wheeler.
There's also a TankInput that shows some ways of handling exotic vehicles. It has a bunch of wheels with friction coefficients and motor forces tuned such that it drives like it has tank treads.
Re: Vehicles - Constantly Slow Down While Turning?
Posted: Wed Jan 04, 2012 12:38 pm
by Astrimedes
First off, thanks for such a great engine and for being so responsive!
I stripped most of the graphics out of the VehicleInput class and added some convenience functions of my own, so that's primarily what I have been using. I'm making an arcadey top-down vehicle combat game, and I'm using the engine to get positions that I'm then outputting to 2D sprites.
You were right about the maximum turn angle - I had it set to Pi / 5, and when I turned it back to the default Pi / 6 the "losing speed while steering" issue went away. Pi / 6 seems to be about the limit, though - if I increase it to anything more than that I start to see that problem again.
Any idea how I could support a maximum turning angle of about Pi / 5 without seeing that problem arise? It feels like the steering should be a little sharper still.
Thanks again!
Re: Vehicles - Constantly Slow Down While Turning?
Posted: Wed Jan 04, 2012 10:31 pm
by Norbo
Changing the VehicleInput to use a maximum steering angle of Pi/5 does not seem to cause the problem alone. There's probably some other difference which is more directly responsible.
With the VehicleInput vehicle, sharp turns at high speed usually result in a lot of sliding (and sometimes rolling), which is a fairly 'realistic' result. For arcadey behavior, the keys are increasing friction and lowering the center of mass to avoid flips.
To try it out, try modifying the demos VehicleInput so that all wheels have higher friction. The relevant line is the "new WheelSlidingFriction(4,5)" parameter of each constructor. Try 10 instead of 4 and 5. Even with a steering angle of only Pi/6, the car will now turn extremely sharply. So sharply, in fact, that it will almost always roll over.
To address the rolling, the center of mass needs to be offset. The VehicleInput already does this with the body.CollisionInformation.LocalPosition = new Vector3(0, .5f, 0); line, but it's not quite sufficient for the new high friction settings. Try changing .5f to .6f. The vehicle should become much less prone to rolling.
You can change the maximum steering angle if you want, but doing the above shrinks the turning radius significantly already.
Re: Vehicles - Constantly Slow Down While Turning?
Posted: Thu Jan 05, 2012 5:36 pm
by Astrimedes
Almost since the beginning of my experimentation I have been modifying most of the "RaycastWheels" objects' constructor values. I had noticed that changing the WheelSlidingFriction constructor values seemed to affect the car's ability to tolerate greater amounts of slipping, but I hadn't made the connection that it would help with turning radius. I've been narrowing down my focus to what needs to be tweaked and what doesn't in order to create an array of varied vehicle types for my game, and your advice pointing me to those values in particular has been helpful. It seems the issue I first noticed with the slow down while turning is indeed the combination of a lot of factors, including at minimum wheel placement on the vehicle, turning radius, WheelDrivingMotor values, WheelSlidingFriction values, and local center of mass.
Thanks again, Norbo, I'm incrementally getting there!