The default car turns very sharply, how to make sliding turns, to the drift?
You can make your car drift by adding angular velocity(torque) to car while turning over time and also decrease friction between car and the surface while drifting(not continuous, i don’t know if there is way to decrease friction using code) so that it slide a little too adding realism.
I tried to set a m_frictionSlip at the wheels in the code, from full zero to a 30000.0, but this did not lead to anything, the car still clings to the road, like a train on the rails …
I also tried to set the friction to 0.0 at the ground, but even so, there is no difference, the car clings to the ground tightly.
In the PhysX vehicles for this there are methods:
setLateralTireForce
setLongitudalTireForce
Are you using translate or linear velocity to move the car?
are you sure you are using below in the script?
#if (!arm_physics)
public function new() { super(); }
#else
{Code}
#end
I use default the Armory vehicle script, name of VehicleBody, in code:
#if (!arm_bullet)
public function new() {
super();
}
#else
//code ...
#end
This script using bullet physic and vehicle class/methods:
https://armory3d.org/manual/api/haxebullet/BtWheelInfoConstructionInfo.html
In this class, formula of friction:
btScalar maximp = wheelInfo.m_wheelsSuspensionForce * timeStep * wheelInfo.m_frictionSlip;
Hello,
Not sure if it resolves for you.
But following are may previous attempt (it is not working fully, so please be cautions)
Not working portion:
If set the friction to very low and only on back, then it did skid, but just skid in circle. If I make all wheels less friction, then it is not skid, only to make it harder to turn (it kind make the turn angle not so sharp at high speed, and require to turn longer to make a turn)
Also, it may not always skid want to skid in break only
// below logic had problem where it will make the vehicle spin
// in circle at turn if the default wheel friction is very small
// in the update method
for (i in 0...vehicle.getNumWheels()) {
// Try to capture before transform, but undefined/null for new properties
var wheelInfo = vehicle.getWheelInfo(i);
...
// brake will trigger slip
if (break)
// if not front wheel, reduce the friction by 80%
if (!wheelInfo.m_bIsFrontWheel)
}
wheelInfo.m_frictionSlip = wheelInfo.m_frictionSlip /2;
}
else
{
wheelInfo.m_frictionSlip = default_wheel_friction;
}
}
So then I just settle at making the default wheel very small like 10 to all wheels
It did not slide, but at least make the turns less sharply.
Not sure if it is any helpful for your question.
For the not sharply turn, it is like in following (where you see instead of sharply turn, at higher speed, it require a larger radius to complete the turn)
Thank you,
This does not solve the problem of sliding, but better than the default
That’s simple, add a force to the vehicle body side, the more you add the more it slides.
This looks like a bug, create an issue on Github about car physics.
I think this is a problem not only in the armory, but in the bullet physic engine.
In a official demo bullet phusic, the vehicle behaves in the same way, without sliding.
I tried to use the very large lateral force to get something like a slidings, but it looks very bad, besides, the vehicle stubbornly resists any lateral forces, trying to keep tough on ground as a train on the tracks, lol
I think without fixe the source code of the btRaycastVehicle.cpp in the Bullet physic, nothing normal can be done…
This test code:
if (left) {
carChassis.applyCentralForce(BtVector3.create(
30000*transform.world.right().x,
30000*transform.world.right().y,
30000*transform.world.right().z));
if (vehicleSteering < 0.3)
vehicleSteering += Time.step;
} else if (right) {
carChassis.applyCentralForce(BtVector3.create(
-(30000*transform.world.right().x),
-(30000*transform.world.right().y),
-(30000*transform.world.right().z)));
if (vehicleSteering > -0.3)
vehicleSteering -= Time.step;
} else if (vehicleSteering != 0) {
var step = Math.abs(vehicleSteering) < Time.step ? Math.abs(vehicleSteering) : Time.step;
if (vehicleSteering > 0)
vehicleSteering -= step;
else
vehicleSteering += step;
}
Sorry for my stupid…
This problem full solved in version 0.6 of armory.