FGear Vehicle Physics (v1.4)

@lazybitgames I found an open source plugin for suspension that should give more accurate results. No idea if possible and how hard will be integrate into FGear but let it here in case you are interested and want to check.

Github:

even with the current fgear you could simulate mcpherson and double wishbone by modifying certain parameters at runtime but the gains you would get have very little effect on the simulation.
the plugin looks cool regardless, i’ll check it out.

The example project doesn’t work in UE5.7

This does work fine, ensure you right click the *.uproject and switch engine versions and you have the 5.7 plugin updated on Epic Launcher.

Also any errors you are getting would help

@lazybitgames i’m having an issue with the fgear suspension , as you can see in the top left i disabled the anti roll , my CoM is in the normal location but when I turn left the car leans left , shouldnt be the opposite?

my other fgear pawn doesnt have that , so wierd im gonna start debugging

yes, it looks odd.
you can try raising the com position further up to check if that makes any difference.

I actually found the fix , the issue was that the SK had a lower clearance , i have no idea why but i raised the body of the car a couple centimeters in blender and it worked

@lazybitgames can you do this test for me? put a long suspension in a car and drive in circles? the longer the suspension the more the car will lean to the inside of the curve

30 in the spring rate , 0.07 up travel and 0.07 down travel should have body roll but 0.3 travel doesnt

I don’t need to do any testing, I know the outcome, it’ll behave as expected.
you can try any vehicle in the example project and see it yourself.
make sure your root bone is at zero(0,0,0) origin.

I’m trying to make a vehicle with an open wheel design. However I noticed that when selecting the convex query option, the wheels end up clipping into walls (surfaces with 90 degree angles)

The line trace doesn’t seem to have this issue. Is there an option that prevents that from happening?

all ray/shape cast based wheels suffer from that issue, fgear is not an exception.
idk why it differs between line and convex in your case.

you can cover the upper portion of the wheel with a collider as a workaround.

if you check my earlier post here I experimented with a better workaround in unity, basically I attached a collider to the wheel which is a bit smaller(%5) then the actual wheel. the collider moves with the wheel so it is kinematic but it can push dynamics objects and prevents clipping to other geometry. it works good on smooth surfaces but it can slow down the vehicle for edge cases like stair climbing or hard landing etc. it needs additional tricks to compensate for those cases. I haven’t tried this with unreal but I think it’s worth a try.

2 Likes

Thanks, that’s a clever solution.

Just minor bugs i found:

In Standard Input > Steer Sensivity(Slider), has the same caption as Steer Speed(Curve).

Also in Shifter type appears “Manuel” instead of “Manual”.

1 Like

@lazybitgames its been a while. Any progress on future updates?

while I made good progress on the features the future of the plugin is undetermined. the state of the code isn’t stable yet, it requires a lot of testing and bug fixing. I don’t want to release it to make customers my testers. I’m thinking of developing my own game with it before any release.

additionally the problem of releasing the plugin is that you make a lot of effort but in return you do not make much money and the code gets pirated in a very short time. for that reason if I release this it won’t be open source anymore or the open source version will be much more expensive.

so do not expect a release in the short term.

EDIT: I think this happens if I take a vehicle that’s child of a streamed level outside the level and the level unloads, taking the vehicle with it. I added a validity check to the FGearUtility::GetWorldTransform function and when the level unloaded, it destroyed my vehicle and teleported my character to World Origin Location (0,0,0). So probably just a workflow issue. Should not put vehicles in streamed levels.

@lazybitgames I’m using FGear along with World Composition and if a landscape is unloaded while a vehicle is on top of it, it crashes Unreal. Is there a validity check I can put somewhere in the code so that it doesn’t crash? I have attached the crash log below. Putting this in ChatGPT says that:

“FGear is trying to read a PhysX body that is already invalid/destroyed/null during a physics substep tick.”

Fatal error!

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffffffffffff

0x00007ffecf881417 UE4Editor-Engine.dll!FPhysicsCommand_PhysX::ExecuteRead() [D:\Build++UE4\Sync\Engine\Source\Runtime\Engine\Private\PhysicsEngine\PhysicsInterfacePhysX.cpp:556]
0x00007ffecf7fe316 UE4Editor-Engine.dll!FBodyInstance::GetUnrealWorldTransform() [D:\Build++UE4\Sync\Engine\Source\Runtime\Engine\Private\PhysicsEngine\BodyInstance.cpp:2571]
0x00007ffec9874408 UE4Editor-FGearPlugin.dll!UFGearWheel::updatePhysicsTransform() [D:\UNREAL PROJECTS\BHR\Plugins\FGearPlugin\Source\FGearPlugin\Private\FGearWheel.cpp:320]
0x00007ffec9856878 UE4Editor-FGearPlugin.dll!UFGearWheel::myFixedUpdate() [D:\UNREAL PROJECTS\BHR\Plugins\FGearPlugin\Source\FGearPlugin\Private\FGearWheel.cpp:221]
0x00007ffec985588d UE4Editor-FGearPlugin.dll!AFGearVehicle::myFixedUpdate() [D:\UNREAL PROJECTS\BHR\Plugins\FGearPlugin\Source\FGearPlugin\Private\FGearVehicle.cpp:691]
0x00007ffec986ceae UE4Editor-FGearPlugin.dll!AFGearVehicle::substepTick() [D:\UNREAL PROJECTS\BHR\Plugins\FGearPlugin\Source\FGearPlugin\Private\FGearVehicle.cpp:585]
0x00007ffec982fa93 UE4Editor-FGearPlugin.dll!AFGearVehicle::Tick() [D:\UNREAL PROJECTS\BHR\Plugins\FGearPlugin\Source\FGearPlugin\Private\FGearVehicle.cpp:524]
0x00007ffeceb432ea UE4Editor-Engine.dll!AActor::TickActor() [D:\Build++UE4\Sync\Engine\Source\Runtime\Engine\Private\Actor.cpp:1093]
0x00007ffeceb0f78d UE4Editor-Engine.dll!FActorTickFunction::ExecuteTick() [D:\Build++UE4\Sync\Engine\Source\Runtime\Engine\Private\Actor.cpp:173]
0x00007ffecfcf297e UE4Editor-Engine.dll!FTickFunctionTask::DoTask() [D:\Build++UE4\Sync\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:284]
0x00007ffecfcfb56f UE4Editor-Engine.dll!TGraphTask::ExecuteTask() [D:\Build++UE4\Sync\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:886]
0x00007ffed1a3ecdc UE4Editor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread() [D:\Build++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:709]
0x00007ffed1a3f0ce UE4Editor-Core.dll!FNamedTaskThread::ProcessTasksUntilQuit() [D:\Build++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:601]
0x00007ffed1a508fd UE4Editor-Core.dll!FTaskGraphImplementation::WaitUntilTasksComplete() [D:\Build++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:1525]
0x00007ffecfd18464 UE4Editor-Engine.dll!FTickTaskSequencer::ReleaseTickGroup() [D:\Build++UE4\Sync\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:564]
0x00007ffecfd1edaa UE4Editor-Engine.dll!FTickTaskManager::RunTickGroup() [D:\Build++UE4\Sync\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:1578]
0x00007ffecf43ad8f UE4Editor-Engine.dll!UWorld::RunTickGroup() [D:\Build++UE4\Sync\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:782]
0x00007ffecf4455f7 UE4Editor-Engine.dll!UWorld::Tick() [D:\Build++UE4\Sync\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1457]
0x00007ffecd369423 UE4Editor-UnrealEd.dll!UEditorEngine::Tick() [D:\Build++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:1720]
0x00007ffecdc850e6 UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick() [D:\Build++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\UnrealEdEngine.cpp:426]
0x00007ff703229bc2 UE4Editor.exe!FEngineLoop::Tick() [D:\Build++UE4\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4836]
0x00007ff70324117c UE4Editor.exe!GuardedMain() [D:\Build++UE4\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:169]
0x00007ff70324125a UE4Editor.exe!GuardedMainWrapper() [D:\Build++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:137]
0x00007ff7032552bd UE4Editor.exe!WinMain() [D:\Build++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:268]
0x00007ff703257fea UE4Editor.exe!__scrt_common_main_seh() [d:\agent_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
0x00007fff0bdf7344 KERNEL32.DLL!UnknownFunction
0x00007fff0c7c26b1 ntdll.dll!UnknownFunction

I wouldn’t put vehicles in streaming levels if it isn’t mandatory.

anyway you can try putting a validity check at the beginning of AFGearVehicle::substepTick function.
there is already a null check so you can append your additional check there.

also it is recommended to use sub stepping, activate it if it’s not on.

1 Like

Thanks! Substepping is already on. I amended my workflow to have a “proxy actor” in streamed levels that spawns the preset vehicle at begin play. So this way, I can place a vehicle proxy in streamed levels and have it spawn the vehicle in persistent level at runtime, since all spawned actors spawn in persistent level at runtime.

If I still get issues, I’ll look into adding the validity check in AFGearVehicle::substepTick function as you recommended.