FGear Vehicle Physics (v1.4)

Im trying to get more steer precision.

The actual steerspeed curve gives the steer speed based on car speed. I want to add the stick (-1.0 / 1.0) to the formula.

For example, if the stick is moved only -0.1 = move at 10% of that steerspeed curve.

This is what im doing:

On FGearStandardInput.cpp in “//apply steering dead zone”

I changed this line:
mSteerInput = FMath::Clamp(mSteerInput, -mCurrentSteeringLimit, mCurrentSteeringLimit);

To:
mSteerInput = FMath::Clamp(mSteerInput * FMath::Abs(mHorizontal * 1.1f) , -mCurrentSteeringLimit, mCurrentSteeringLimit);

It gives me more precision on steer for small variations, very useful on high speeds. The cons is that on drop the stick the steer goes to 0 instantly, which may cause issues in some turns/circusmtances.

With the original code, when you drop the stick it goes to steer 0 but smooth.

So, what will be the best way to fix and on drop the stick get the same results as with original code, or maybe i should edit in other line to get same/best results?

use your formula if input is nonzero and stick to original when target is zero?

Yeah, tried, but not seems 100% accurate, sometimes the wheels not moves as smooth as original mmm, you mean this?

if ( mHorizontal != 0.0f ) {
mSteerInput = FMath::Clamp(mSteerInput * FMath::Abs(mHorizontal * 1.0f) , -mCurrentSteeringLimit, mCurrentSteeringLimit);
}
else { mSteerInput = FMath::Clamp(mSteerInput, -mCurrentSteeringLimit, mCurrentSteeringLimit); }

EDIT: I mean, sometimes looks they do some tremble when you drop stick.

EDIT2: Oh, yeah, because on drop the stick from max side left-or-right it not goes to 0, it may do some 0.01 right and left due that suddenly drop . Mm i guess i will need to do some comparision or do it bettween some max-min values to avoid this.

yea sth. like that, of course you might need to debug and fix if there are any unforeseen issues.

I think you could add some kind of linearity to your input, pretty much like Forza and in particular Racer implements. Where lower values provide more accuracy near the center but less accuracy near full lock. Higher values provide more precision near full lock but less accuracy near the center.

You can find the racer implementation here

Yep, exactly, some linear is what i want to achieve too. Im bad at maths so not understand very well that formulas.

I tried something simple like a lerp in both cases and seems works enough. Still sometimes it looks not does 100% as it should, but much better now, i need various attempts too see any kind of “tremble” or “no smooth” effect on drop the stick and is very low/subtle. Im doing this:

if ( mHorizontal != 0.0f ) { 

mSteerInput = FMath::Lerp(mSteerInput, FMath::Clamp(mSteerInput * FMath::Abs(mHorizontal * 1.0f) , -mCurrentSteeringLimit, mCurrentSteeringLimit), 0.8f);
}
else { mSteerInput = FMath::Lerp(mSteerInput, FMath::Clamp(mSteerInput, -mCurrentSteeringLimit, mCurrentSteeringLimit), 0.8f); }

Im still testing to see if i can really fix, if any idea or what add/change in that code let me know.

Btw, Lazybitgames, i guess some slider under “steer speed” curve on the BP to add the stick to the formula where 0 is disabled and any amount set the multiplier on mHorizontal to set the accuracy,etc… will be great for next update maybe?

Also, what i should add to set inertia scale inside FGearWheel.cpp ?

I want to try some idea to change the inertia scale Z with more or less car steer that depends on mLatFrictionForce to improve countersteer.

I mean, if the friction force is to one side, and you are trying to turn to the other side, decrease the inertia scale z for easy countersteer.

No idea if will work as expected and will fit my needs but want to try. Or if you prefer i can send you an email about this.

AFGearVehicle::setInertiaScale is the function but never tried updating inertia at runtime, let me know if that works.

If you never tried, this means update the inertia XY or Z at runtime maybe is not a good idea?

Don’t know how to get it working, i checked the FGearVehicle.cpp and there is a:
“void AFGearVehicle::setInertiaScale(FVector iscale) {”.

But dont know what to do inside the FgearWheel to set only the Z one for my case.

There is a “//store local inertia tensor matrix” - “mLocalIIT.M[2][2] = 1.0f / inertia.Z;”

But i guess this is from the physics one, i dont want to change the Z tensor on the physics, just the InertiaScale from Z on the Fgear BP.

This is the actual condition im working:

		if ( mHasContact && mAccel > 0.0f && mLocalVelocity.X > 0.0f && mLateralForce.Size() > 1000.0f )
		{	
	       if ( mCurrentSteer > 0.0f && mLatFrictionForce > 1000.0f ||  // Left to Right
		        mCurrentSteer < 0.0f && mLatFrictionForce < -1000.0f )  // Right to left
			{    
				// Higher *X works as normal. With lower it decreased the lateral force
				//mLatFrictionForce = mLatFrictionForce * 0.5f; // Allows stop the car rotation for better aim on curves // Basic
				
				//mLatFrictionForce = FMath::Lerp(mLatFrictionForce * 0.5f, mLatFrictionForce, 0.01f); // With lerp
				
				mLatFrictionForce = FMath::Lerp(mLatFrictionForce * (mCurrentSteer/35.0f), mLatFrictionForce, 0.01f);  //  Better steer & counterspeed
							
		    }
	    }

So, i want to add a formula using mCurrentSteer & InertiaScale Z to see if it combines well to get the overall steer/countersteer behaviour im looking.

Can you give me the working code to set the inertia scale inside FgearVehicle? If maybe is too complex i can pay for that.

Can you give me the working code to set the inertia scale inside FgearVehicle?

I’m not sure what you are asking, the function is there and open?

No, i mean, i want just the working code to edit the InertiaScale Z inside the FgearWheel.cpp . In the same way i can use variables to edit like “mLatFriction” etc… that allows me to edit stuff to get the behaviour i want for the car.

So, i need a variable, let say “mInertiaScaleZ” to play with, in the same way i can do with the others. Then i can put that variable in my formulas to edit the inertia scale Z where i want.

Or maybe what i want to do is not possible?

what do you mean by “working code”? you have all the source code of fgear what else I can give you.

Got the steering accuracy with 0 bugs and much better feel in all ways.

Inside FGearStandardInput.cpp at //steering speed limit

Changed this line
mCurrentSteeringInput = FMath::Lerp(mCurrentSteeringInput, mTargetSteeringInput, steerTime);

By

if ( mHorizontal != 0.0f ) { 
mCurrentSteeringInput = FMath::Lerp(mCurrentSteeringInput, mTargetSteeringInput, steerTime * FMath::Abs(mHorizontal * 1.1f));
}
else { mCurrentSteeringInput = FMath::Lerp(mCurrentSteeringInput, mTargetSteeringInput, steerTime * 0.5f); }

Adding “FMath::Abs(mHorizontal * 1.1f)” on SteerTime it seems to do that desired linear speed that depends on how much the stick is moved from center.

Also i set to “* 1.1f” due at least with my XBOX 360 gamepad and how i drive when i try to steer max, usually get around 0.95-0.90, so with that i get sure to always get the full steer speed desired.

Another addition was on “else” with “* 0.5f” for the steerTime. I have 9 on InputGravity for better countersteer, the bad thing is on drop the stick, the wheels goes to 0 steer too fast causing sometimes unwanted results. With 0.5, wheels goes to 0 steer more smooth giving a better driving feeling.

Still testing to be sure it works well in all scenarios, but looks promising.

1 Like

Evening,
image

What would be the Fgear equivalent in Blueprints for this?, tried a few things but stuck.

++Update Ignore this :slight_smile: found alternative for what I was looking for.

Hi @lazybitgames,

I wonder if have you planned to improve UE5 support, in particular implement async physics tick? even if its a paid upgrade for UE5 :smiley:

I ask this because I think FGear is an awesome product and hands down the best vehicle physics plugin for UE and Unity.

Thanks!

@Kromen I must agree in all respects.

I do believe @lazybitgames Will do their utmost to support UE5 and Chaos to bring this to the standards of UE4 PhysX and better. I do think that some engine fixes are required before this is possible and 5.1 (when its released) may or may not help but… I can’t talk for Yunus but I know his support has been superb from day one.

I’m confident we will see a fully stable Fgear for UE5 and I can’t wait for that :slight_smile:

1 Like

yes, we are planning to maintain fgear ue5 port until it becomes as stable as ue4 version but it depends on the stability of chaos itself. we are hopeful about the upcoming releases :crossed_fingers:

1 Like

Thank you guys, that is awesome news! and totally understandable.

we are hopeful about the upcoming releases :crossed_fingers:

Hehe, you and all of us who love FGear!

Thanks!

it’s not correct, checked the original unity version and it seems that this was incorrectly ported. it’s very difficult to feel the difference so we have missed this for a long time.

thanks for the heads up.

1 Like

Awesome work on the UE5 port.

I’ve migrated the changes into my modified plugin and they seem to work well - apart from Convex trace types, specifically on Landscapes, it vibrates like crazy (works fine on meshes though).

The biggest change in my personal version of the plugin is changing all the function signatures to match that of the Unreal syntax standard.

Is there any plans to update your code to match these standards?

I use Rider for Unreal and it was getting too noisy - so I eventually decided to resolve all the syntax warnings.
Could imagine others would be getting the same on their end.

Improvements would be the following:
Change signatures to start with a capital letter
Make use of const in function parameters
Convert getter functions to const (where applicable)
Update variable names to match Unreal conventions (this one is less important imo)

Alternatively, if you have the support capacity, perhaps owners of the plugin could be invited to a private GitHub repo and would be able to contribute to the plugin?
This is not uncommon with some other plugins I’ve purchased