FGear Vehicle Physics (v1.4)

Im using “mVehicle->getSteerDeltaAngle(true)”, for a counter steer condition, but having some problems.

At some point, if you turn fast or spin, the sign goes to opposite, from -90 to 90,etc… even if the car is constantly turning to the same side always.

This breaks the condition and its applied in wrong scenarios.

Is there any way to fix that?

it’s not just about spinning direction, that function assumes the vehicle going forward, you should detect the case when the vehicle’s velocity is not aligned with the vehicles forward direction(you can use a dot product) and possibly invert the forward vector.

1 Like

You mean something like what you did here?:

FVector velDir = mVehicle->getVelocityDir();
FVector dir = mVehicle->getForwardDir();
float sign = FGearUtility::Sign(FVector::CrossProduct(dir, velDir).Z);

I tried, better but still fails. I found adding this one to the condition helps:
float rollZ = FGearUtility::getWorldTransform(mBody).Rotator().Roll;

But still fails in a few frames, enough to make the car get stuck.

There is no other Rotation variable that already gives always the correct values? I tried mLocalVelocity.Y and other lateral stuff but all them fails in one or other scenario.

well you may not be able to get a result that works right away, find the failing spots and make adjustments as needed. you just need to debug the code to see what numbers are failing.

I realized the cars in the new SandBox 2 all them have the Mx/My/Mz Momentum Scale to 0.0.

But the original ones, Mx/Mz are 1.0, and for (My)Roll it can be from 0.2 to 1.0 in some cases.

I cant find any behaviour difference in Mx/Mz, but (My)Roll makes the car like more traction/friction.

Any reason for that change in new cars? or just to make more slide/drift?

if you read the documentation it says:

All tire models generate Fx, Fy and My. Mx and Mz are only generated by MF6.1 tire model.

there is no specific reason for their values, if you try a very large value for My you can observe that the vehicle will rear up.

1 Like

How i get LateralFriction or LateralScale,etc… per axle?
Only get working this:
mAxle->getWheelOptions()->getLateralFriction();
mAxle->getWheelOptions()->getLongitudinalFriction();

Or if they are axle*wheel:
mVehicle->getAxle(0)->getLeftWheel()->getLateralSlip();

But when the get/set is only available for axle, im unable to find how ¿?

In blueprints i see how:

But via code, tried FrontWheelOptions, or WheelOptions0 or similar but nothing worked. Checked other .cpp but cant find any reference how i should do that. ¿?.

How do you make it so the fgear camera cant go through walls and has a collision

in the project settings there is a clip value. change that.

wheel options are per axle, shared between wheels.
after doing any modification, you should call Axle.applyWheelOptions function.

wheels also store local values too but they can’t be read from BP right now, you can only modify them per wheel like Wheel.setLatFriction, if you want to access them per wheel you need to add your own BlueprintCallable getter functions.

1 Like