FGear Vehicle Physics (v1.4)

hello @lazybitgames When I use their preconfigured cars, at high speeds on highways they do not lose control, but when I use my own cars they all lose control at high speeds, what suggestion can you give me? They basically have the same physics configuration and physical model of the car.

can’t say much, could be due to multiple reasons.

maybe you forgot to set tire models, in such cases a default simple tire is created but that model is not much stable. anyway if you mail your vehicles save file I can take a look.

How can I simulate sand with FGearPhysicalMaterial?
I lowered the friction and increased the roughness, but the vehicle slides as if it were on ice.

you can’t.

FGearPhysicalMaterial only implements friction, roughness has no effect(stated in the documentation).

you can do some custom stuff like detect that the wheel is on sand and apply some artificial force against the movement of the vehicle.

This is pretty bad, simulating the type of terrain would be a basic thing to expect from a vehicle physics system. Do you have any intention of implementing this in a reasonable time frame, or at least making it compatible with Unreal’s standard physics material?

when it comes to extra features we do not promise anything, they’re just demonstrations, this is the case since the beginning.

you can request a refund, we are open to it.

This is not an “extra”, this is a core functionality for a physics system, it’s something basic in Unreal standard physics, what is expected from a plugin is that it improves, not worsens or removes something that already exists.

Think better about the completeness and reliability of your product before being adamant and offering just a refund, my project is already completely dependent on your plugin.

what is that core functionality in unreal physics, can you define it, I’m not aware of that.

I doubt that what you want and what you define as “core functionality” are not the same thing.

afaik there is no physics setting that can simulate a wheel in mud or sand.

if you want a wheel to have a drag effect then you can imitate the behavior somehow, gave you a hint earlier and it is pretty simple to implement. if you are not willing to do simple stuff then you’ll have hard time making games.

In my original project I had already simulated the types of terrain I needed using the standard vehicle and physical material in Unreal (dirt, sand, asphalt), basically adjusting Friction / Static Friction / Friction Combine Mode. Although, the values ​​of my “Tire Lat Stiff” of the “wheel BP” were very high, also the physical materials of my “Tire Config” had more friction, so I probably wouldn’t be able to simulate ice (which is not useful to the project).
Maybe if I increase the corresponding values ​​in your plugin, I can achieve a similar result.
Anyway, I’m sorry for being harsh, every question or suggestion I leave here is with the aim of improving your product and not the other way around.

it is not just the tire friction that affect the vehicle on sand, you can’t achieve a slow down by playing with friction values.
you need to imitate the counter force generated by the sunk wheels, here is a quick attempt:

As you said, changing the parameters made no difference on a slippery surface.
What I was trying to do, following your first suggestion, was to apply a counterforce to each wheel that came into contact with the sand surface. I used a line trace to identify the surface and then calculated the counter force according to the speed of the wheel (Lat/Long), in addition to calculating the compensations if 4WD and Diff Lock were activated.
But in the end it was a bit heavy/inconsistent (on the Android device), perhaps because it is a timer with a for loop in BP.

The only solution I have found so far in terms of performance, was to calculate only in relation to the vehicle, and also to stop distinguishing between lat/Long speeds. It’s far from perfect, and I need to find the correct values, but the sensation of slowing down when entering the terrain, maintaining momentum, loss of traction at low speed, etc. is already noticeable.

Your example looks great.
Is your solution lighter? Can you show me how to implement it?

this is quite rough but can give you some ideas:

1 Like

It’s working well, but there’s no lateral resistance, the vehicle remains free and can gain speed while spinning.
I added an “Add Torque” which solved the problem well and gives the feeling of actually being on the sand with a well-contained skid, but I don’t know if this is the best solution, what do you think? (Especially in terms of performance, I’m afraid that all these applications of force will end up compromising the game’s performance.)
(PhyMat: Fri: .2 / Rou: .5)

there is lateral resistance too but since the lateral movement is slower the resulting resistance is also low. I would use the local velocity vector and scale forward and lateral resistances separately.

all of those addForce, addTorque etc. are summed up and applied at the end of a physics tick, they’re just vector additions so they won’t have much effect on the performance.

we detected an issue with the enhanced input support, working on a hotfix


Whats the simplest way to detect if a value is increasing or decreasing?

Inside FGearWheel.cpp, I was trying this:

float actual = 0.0f;
float previous = 0.0f;
float value = mAccel ;

actual = value;

if ( actual > previous) // Accel
{   mOstiax = 11111111.0f;}

else if ( actual < previous) // Decel
{   mOstiax = 44444444.0f;}

else if ( actual == previous) // Constant or none.
{   mOstiax = 66666666.0f;}

previous = value;

Accel and Constant/None ok, but not Decel.

Desired is detect if the car is accel/decel (and how much) or if // Constant or none.

I tried with mLocalVelocity.X and other values that goes up/down with same result.

Any idea?

well if that code is the actual code that you’re using then it is normal that you get weird results since you don’t store the previous value at all, it is always zero because it is just a local variable.

Sorry, pasted an old code, this actually works, just setting a lerp on previous, but no idea if there is a better way:

mActual = mVehicle->getEngine()->getThrottle();

if ( mActual > mPrevious) // Accel.
{   mOstiax = 11111111.0f;}

else if ( mActual < mPrevious) // Decel.
{   mOstiax = 44444444.0f;}

else if ( mActual == mPrevious) // Same.
{   mOstiax = 66666666.0f;}

if ( mActual == 0.0f) // None.
{   mOstiax = 00000000.0f;}

mPrevious = FMath::Lerp(mPrevious, mVehicle->getEngine()->getThrottle(), 0.8f); 

So, im guessing using the 0.8 can set the amount time to tell the difference, then on each if/else if do a substraction of actual-previous with absolute values.

Btw, if you can add this on the plugin can come very handy.

I would do 2 things differently.

first, acceleration should be based on velocity not throttle, the vehicle can accelerate without throttle. you can use Vehicle.getKMHSpeed for that.

second, it is good to smooth out the stored values since physics data is mostly noisy. in your case you have smoothed the previous value but I would smooth the actual value and compare with the previous. also the way you smooth with “Lerp” is frame dependent, you better use delta time there like Lerp(x, y, z * dt).

1 Like

Can this be improved in some way to avoid car stop accelerating on change gear and getting like some “stuck” sometimes. It prevents the fluid drifting:

	//keeps vehicle from going faster than engine rpm limit
	//this is an artificial force so take clutch power into account here
	//mSpeedOverflow is multiplied with clutch power above in applyRpmLimit
	if (mSpeedOverflow > 0.0f)
	{
	currentForce = FMath::Sign(-mLocalVelocity.X) * absLngFriction * mSpeedOverflow;		
	}

Disabling that, drifting is so fluid and doing 360Âș are much better. Btw, without it, at some times it may accelerates too much, so it has his pros/cons. Wonder if there are some ideas i can test here to do the same but in a different way that not blocks/brake wheels in some way?