[solved] In the vehicle class not working of frictions

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:

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(); }

I use default the Armory vehicle script, name of VehicleBody, in code:

#if (!arm_bullet)
public function new() {
//code ...

This script using bullet physic and vehicle class/methods:

In this class, formula of friction:
btScalar maximp = wheelInfo.m_wheelsSuspensionForce * timeStep * wheelInfo.m_frictionSlip;


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;
				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)

1 Like

Thank you,
This does not solve the problem of sliding, but better than the default :wink:

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.

1 Like

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 :smiley:

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) {
			if (vehicleSteering < 0.3)
				vehicleSteering += Time.step;
		} else if (right) {
			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;
				vehicleSteering += step;

Sorry for my stupid…
This problem full solved in version 0.6 of armory.

1 Like