FGear Vehicle Physics (v1.4)

@lazybitgames which options affect the weight of the vehicle? Only the linear and angular damping of the physics body? I’m trying to make the tank heavier so that other vehicles can’t hit it and send it flying

I wouldn’t modify damping, set mass as usual and tune the feel with inertia scale (in general settings).

1 Like

Thanks!

@lazybitgames ,there are 3 different ways for Traction Control:

1- Vehicle → ASR || Used in UFGearWheel::updateSlipValues()

Overrides mLongitudinalSlip with mLngSlipOverride which changes mSlipRatio too.

2- FGearArcadeAssits → Traction Assists
Changes LongitudinalFriction & LateralFriction that on UFGearWheel are:
mLatFriction
mLngFriction
Which are multipliers for mLngFrictionForce & mLatFrictionForce

3- Vehicle → Optimal Slip Weight
That is renamed as OptimumSlipWeight and found in vehicle:
mOptimumSlipState = mOptimumSlipWeight;

That seems what it does is the same as ASR ¿? Or whats the difference ¿?
optimalSlipState = FMath::Max(optimalSlipState, FMath::Max(mVehicle->getASR(), mVehicle->getABS()));

Are any of this deprecated, safe to use or one is better/recommended?

it’s difficult to simulate real life traction control methods unless you simulate at 1000hz or more. ASR option is the safest and works quite good. the idea is to use the best slip value and sync the wheel speed with ground.

Vehicle → Optimal Slip Weight : as mentioned in the change log this is an experimental feature and it does not prevent any slip but trims excessive slip values for optimal traction. unlike ASR this does not interfere with the wheel rotation speed. this feature might be removed in the future.

FGearArcadeAssits → Traction Assists : this is quite simple and not realistic at all, could be used in a specific scenario but you can skip this.

Hi, is it possible to have a suspension less vehicle?
No matter what I am trying the wheels drop below ground level and the vehicle acts like a buoy in water.

Maybe this vehicle use case is not possible. As it should be completely rigid on the street, has low ground clearance and normaly is a tracked vehicle.

Best regards

i don’t think it is possible.
you could try sth. with a very short suspension travel like 1mm but that would require a lot of precision to behave properly.

let’s say your suspension spring rate is 50 and suspension up/down travel is 0.1, you reduce up/down travel down to 0.001 and to compensate you need to multiply the spring rate with 100 but that would be very stiff and will not be stable unless you simulate at sth. like 10000fps. instead keep the spring rate at 500, increase damping like 3x to 5x and set hard contact scale to 0.1, this will lead to sth. you can drive around but still very bumpy…

@lazybitgames

Found that what fixes my traction problems using ASR is not mLngSlipOverride, is this code:
float scaler = 1.0f - (lowSpeedCase ? 1.0f : mVehicle->getASR());

With 0.5 fixes. My problem is on corners at lowspeed, doing zig-zag, where lot of braking-accel-countersteer happens.

The car not turns and it slides too much with low response, but ASR at 0.5 fixes, but this code not the lngSlip.

Can you explain what this code really does?

My guess, having in mind is at netTorque function, a scaler that substracts from deltaV, maybe if the car gets overspeed creating slip, this number removes X from netTorque to match speeds ¿?

the “scaler” scales down the speed change of the wheel caused by net torque. when this happens the wheels rotation speed will be almost the same speed as travel speed resulting a very tiny slip. to compensate we use the optimal slip value when asr is active and we get a nearly perfect grip. it’s hacky but it is a parametric way to reduce tire slip.

1 Like

@lazybitgames what settings would I have to mess with to make the vehicle have a lot of torque but not a very high top speed. My tank is a bit weak when going uphill, but messing with the engine torque scale makes it go faster too so trying to offset that

So I did some weird stuff and got something working:


So I just set a variable as the max allowed speed, check the linear velocity of the root mesh and stop throttle if it goes above the allowed speed:

Besides this, set the engine’s torque scale to 5

Reduced the transmission to a single forward gear with a gear ratio of 5, because I like that number

Set torque share on all axles to 0.5 instead of 0.125 (1/8 axles)

That gives me enough torque to climb mountains in my rustbucket without the vehicle going hypersonic but there’s also some bugs I’m trying to figure out.

First is the obvious jump the moment I accelerate, which I wonder if it can be solved by modifying the gear ratios.

2nd is, the moment I let go of the throttle, the vehicle starts moving backwards in a quite noticeable manner.

@Zarrar2802
Try with Final Gear Ratio in Transmission, it decreases top speed by adding Acceleration.
You can play also with rolling resistance, DriveTrainFriction and anything that slows down by speed.

I’ll have a look at those variables

Okay so Friction Torque in the Engine Component was responsible for causing that reversing movement. Set that to 0, which also caused the vehicle to no longer slow down when throttle is released.

Drivetrain Friction helped to slow down the vehicle when I released the throttle,

Final Gear Ratio worked like a charm, setting that to high value allowed me to skip my own hacky top speed code.

Also set the Engine Torque Scale value back to default.

Final Gear Ratio was exactly what I was looking for. Thank you!

@Davit_Masia Would you happen to know how the gear up and gear down ratios work? I don’t quite understand them

Is basicaly at what % of that gear speed will gear up or down.
Checking your gears you have only 3 from 6, 8, 12, tanks can go up to around 50-60 km/h and 4-6 gears or similar.

In sandbox2 level, there is a trailer which is lot heavy like a tank, you should check all their params and use in your tank to check which ones works better for your needs. After that i just trial/error changing values thousands of times until get the desired behaviour and understand the quirks of the FGear. Not only params, also the physics assets, because you may want to add linear/angular damping, inertia conditioning, smooth collisions and set the collision box correctly that if you dont use custom collision it will be used as a physics mass that will contribute a lot in the final tank behaviour.

1 Like

@lazybitgames
The problem is that the actual ASR aproach breaks the overall drifting behaviour.

Because i need traction on the commented situations that ASR-Scaler fixes well, but not the lngslipoverride due adds too much grip.

Atm i disabled the lngslipoverride and works, i got that plus traction to countersteer thanks to the scaler while keep the car drifting when needed.

I suggest split the ASR assist in two like:
ASR OverSpeed
ASR Anti-Slip

Another thing, setting the ASR, scaler fix is applied always and not when is needed which also reduces smooth/drift turns.

So im guessing will be something like this?:
float formula = FMath::Clamp (overspeed ratio, 0.0f, 1.0f);
float scaler = 1.0 -FMath::Lerp(0.0f, formula, mVehicle->getASR());

What i should do to get the correct overspeed?

Thank you! I actually did use the trailer as the template for the tank. Removed the gear ratios afterwards. I’ll put them back and see how it goes. You’re right about the physics asset, took me a while to get the center of mass right by adjusting the physics asset

After more testing the lngslipoverride only becomes a real problem for drifting at 80-90, having in mind i will stick on 50 and after test all combinations from now seems is ok with it. i can reduce some latfriction if needed to compensate the extra grip by lnslipoverride, so no problem.

About a modulated scaler, still playing around but using lngslip values seems does the work:

float accelInp = mVehicle->getEngine()->getThrottle(); 
float formula  = FMath::Clamp (FMath::Abs(mLongitudinalSlip)*mVehicle->getASR(), 0.0f, 1.0f); 
float scaler   = 1.0 - FMath::Lerp(0.0f, formula *accelInp, mVehicle->getASR());|

Hi, maybe we do something wrong.

Any mesh component with collision on will be ignored inside the vehicles, but only if the vehicle is colliding with something static in the world.

As an example, I did add a simple cube in front of the vehicle.

A third person character running against the cube will collide, the vehicle colliding with any other vehicle will collide. But driving into a wall or building will not collide.

Unreals chaos vehicle do work with such a setup.

Any tips or does this not work and we are forced to go back to unreals chaos vehicles?

I tried what you said and added a cube(static mesh component) in front of a vehicle. initially it didn’t collide with other vehicles(not only the cube but the whole vehicle body didn’t collide) but when I change the collision profile to default or pawn then it started colliding properly.

the problem I see is that normally the root component should dictate the collision profile when the components are welded but in this case it just breaks it and I don’t know why at the moment.

In line with the discussion of collision of individual bodies, it is not possible to animate a bone of the car if it has a physics body attached. Also setting the wheel bone name at runtime crashes the engine.