velocityx
Member
|
vehicle stabilizing bar
so i was wondering how to make the vehicle from the tutorial so it won't flip so much,i was looking around and found edy's vehicle physics for unity,he gave the code for the stabilizing bar,the thing that made the vehicle not that easy to flip,but i wonder how to apply it to esenthels system
var WheelL : WheelCollider;
var WheelR : WheelCollider;
var AntiRoll = 5000.0;
function FixedUpdate ()
{
var hit : WheelHit;
var travelL = 1.0;
var travelR = 1.0;
var groundedL = WheelL.GetGroundHit(hit);
if (groundedL)
travelL = (-WheelL.transform.InverseTransformPoint(hit.point).y - WheelL.radius) / WheelL.suspensionDistance;
var groundedR = WheelR.GetGroundHit(hit);
if (groundedR)
travelR = (-WheelR.transform.InverseTransformPoint(hit.point).y - WheelR.radius) / WheelR.suspensionDistance;
var antiRollForce = (travelL - travelR) * AntiRoll;
if (groundedL)
rigidbody.AddForceAtPosition(WheelL.transform.up * -antiRollForce,
WheelL.transform.position);
if (groundedR)
rigidbody.AddForceAtPosition(WheelR.transform.up * antiRollForce,
WheelR.transform.position);
}
|
|
11-20-2012 06:41 PM |
|
cat555
Member
|
RE: vehicle stabilizing bar
I'm looking to implement this, but the key factor missing is that we cannot know the individual compression for each wheel at a given instant.
For example, when turning left, we need to know how much compressed is the WHEEL_RIGHT_FRONT, to try to compensate that, by applying a force to the car in the wheel position, by some amount. This would the the car more stable... we can do it for the two axles for instance...
But i couldn't find in Esenthel a way to get that information (compression or distance) individually by wheel. @Esenthel (or anyone that knows ), is possible to get this kind of information? I guess that Phys3 gets this information available...
Thanks!
(This post was last modified: 08-26-2014 07:50 PM by cat555.)
|
|
08-26-2014 03:06 PM |
|
para
Member
|
RE: vehicle stabilizing bar
I think it's possible to derive this information.
You can get each wheels matrix for example, maybe calculate the 'suspension compression' from this?
I'm using vehicles in my game and made them a lot more stable than they are in the tutorials. Firstly by setting the center of mass more suitably, then by tweaking other parameters (I suggest you set-up a quick gui, wire all the parameters to it and experiment). I'm also throttling down steering a bit at higher speeds so you can't make as sharp turns, which seems to help as well. I'm not entirely satisfied yet but I still have some options left to explore, if they won't work I'll attempt to make something like that stabilizer bar you described.
|
|
08-28-2014 08:20 PM |
|
cat555
Member
|
RE: vehicle stabilizing bar
Hi, yes it would be possible to derive, but i think it's better to "trust" in physics information for this. This will allow to compensate with the correct force.
Also, @Esenthel already included this days ago: http://www.esenthel.com/community/showth...6#pid48366
I wasn't able to test yet, since it wasn't released to Linux yet. As soon as it will be released, i will test this and put my test results over here.
|
|
09-01-2014 11:07 AM |
|
cat555
Member
|
RE: vehicle stabilizing bar
My actual option on this, follows a basic approach (but works quite well indeed) - apply a force (continuously or not) in the car, that works like an extra gravity force... this will help in overall stability of the car. My actual implementation (prototype purposes) follows this:
Code:
REP(WHEEL_NUM)if(onGround((WHEEL_TYPE)i))
if(Dist(wheelLongSlip((WHEEL_TYPE)i)/0.75, wheelLatSlip((WHEEL_TYPE)i)/0.20)>0.3)
{
Car.addForce(Vec(0, -2500, 0), Car.pos());
}
Actually this is a Nvidia's approach - see PhysX Knowledge Base/FAQ - How do I make my vehicle less "floaty"? - http://www.nvidia.com/object/physx_knowledge_base.html
|
|
09-10-2014 10:33 AM |
|