FGear Vehicle Physics (v1.4)

it is not possible to animate a bone of the car if it has a physics body attached

there is a call to mesh->SetAllBodiesSimulatePhysics(true) in vehicle beginplay, that’s the reason, I guess i’m gonna remove that.

setting the wheel bone name at runtime crashes the engine

just tried that without a problem. even setting an invalid bone name shouldn’t cause a crash, can you send a crash log or a specific test case.

@lazybitgames It looks positive/negative camber values are inversed, it should be:
Negative = Top wheel in
Positive = Top wheel out

But feeling works as expected:
// Increase Front = More rotation
// Increase Rear = More stability

Toe values, positive & negative are visually ok, but maybe the feeling is not as it should?
In theory using Toe:
// Front In : Increase Stability at cost of responsivenes. Too much = underSteer
// Front Out: Increase turn in, can cause vague steering
// ----------
// Rear In : Increase Stability and better drive out of corners.
// Rear Out: Increase vehicle rotation, too much = oversteer

But for example i tried toe in front -10/10 and the feeling is the same.
At 10 positive is ok, “Stability at cost of responsivenes, Too much = underSteer”
But -10 negative gives exactly the same feel ¿?.

Can you double check please?

Hi,

to clarify did you get the attached cube colide with static colliders inside the world or did it not work?

If not maybe the reason has something to do with addnig the forces directly to the FBodyInstance.

This is the error I got

UnrealEditor_FGearPlugin!AFGearVehicle::getBoneTransform() [D:\build\U5M\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\FGearPlugin\Source\FGearPlugin\Private\FGearVehicle.cpp:349]
UnrealEditor_FGearPlugin!UFGearWheel::updateComponentTransform() [D:\build\U5M\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\FGearPlugin\Source\FGearPlugin\Private\FGearWheel.cpp:167]
UnrealEditor_FGearPlugin!UFGearWheel::execsetBoneName() [d:\build\U5M\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\FGearPlugin\Intermediate\Build\Win64\UnrealEditor\Inc\FGearPlugin\UHT\FGearWheel.gen.cpp:1961]
UnrealEditor_CoreUObject!UFunction::Invoke() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:7460]
UnrealEditor_CoreUObject!UObject::CallFunction() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1175]
UnrealEditor_CoreUObject!UObject::ProcessContextOpcode() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:3153]
UnrealEditor_CoreUObject!ProcessLocalScriptFunction() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1242]
UnrealEditor_CoreUObject!ProcessScriptFunction<void (__cdecl*)(UObject *,FFrame &,void *)>() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1070]
UnrealEditor_CoreUObject!ProcessLocalFunction'::2’::<lambda_1>::operator()() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1320]
UnrealEditor_CoreUObject!ProcessLocalFunction() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1339]
UnrealEditor_CoreUObject!ProcessLocalScriptFunction() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1242]
UnrealEditor_CoreUObject!UObject::ProcessInternal() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1371]
UnrealEditor_CoreUObject!UFunction::Invoke() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:7460]
UnrealEditor_CoreUObject!UObject::ProcessEvent() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:2211]
UnrealEditor_Engine!AActor::ProcessEvent() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\Actor.cpp:1456]
UnrealEditor_Engine!AActor::BeginPlay() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\Actor.cpp:4777]
UnrealEditor_Engine!APawn::BeginPlay() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\Pawn.cpp:183]
UnrealEditor_FGearPlugin!AFGearVehicle::BeginPlay() [D:\build\U5M\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\FGearPlugin\Source\FGearPlugin\Private\FGearVehicle.cpp:165]
UnrealEditor_VehicleBaseForProjects!ABaseVehicle::BeginPlay() [I:\DriveTown\Plugins\VehicleBaseForProjects\Source\VehicleBaseForProjects\Private\BaseVehicle.cpp:301]
UnrealEditor_Engine!AActor::DispatchBeginPlay() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\Actor.cpp:4713]
UnrealEditor_Engine!AWorldSettings::NotifyBeginPlay() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\WorldSettings.cpp:362]
UnrealEditor_Engine!AGameStateBase::HandleBeginPlay() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\GameStateBase.cpp:228]
UnrealEditor_Engine!UWorld::BeginPlay() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\World.cpp:5916]
UnrealEditor_Engine!UGameInstance::StartPlayInEditorGameInstance() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\GameInstance.cpp:567]
UnrealEditor_UnrealEd!UEditorEngine::CreateInnerProcessPIEGameInstance() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp:3182]
UnrealEditor_UnrealEd!UEditorEngine::OnLoginPIEComplete_Deferred() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp:1627]
UnrealEditor_UnrealEd!UEditorEngine::CreateNewPlayInEditorInstance() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp:1890]
UnrealEditor_UnrealEd!UEditorEngine::StartPlayInEditorSession() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp:2913]
UnrealEditor_UnrealEd!UEditorEngine::StartQueuedPlaySessionRequestImpl() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp:1204]
UnrealEditor_UnrealEd!UEditorEngine::StartQueuedPlaySessionRequest() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp:1105]
UnrealEditor_UnrealEd!UEditorEngine::Tick() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:2038]
UnrealEditor_UnrealEd!UUnrealEdEngine::Tick() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\UnrealEdEngine.cpp:533]
UnrealEditor!FEngineLoop::Tick() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:5625]
UnrealEditor!GuardedMain() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:187]
UnrealEditor!GuardedMainWrapper() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:128]
UnrealEditor!LaunchWindowsStartup() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:282]
UnrealEditor!WinMain() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:339]
UnrealEditor!__scrt_common_main_seh() [D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32

This is the code

EDIT: After further testing. It works with a “delay until next tick” or small delay. Does not work on construction.

Hi @lazybitgames,

I might have found the issue here.

It seems that unreal will not know of attached collisions/meshes if SetSimulatePhysics/SetAllBodiesSimulatePhysics is called in begin play. Maybe the extra physic bodies are created before SetSimulatePhysics will create its own physics body and are never welded into the main phyiscs of the vehicle.

If setting simulate physics directly in the blueprint, by checking the box, the collision does work.

If setting the SetSimulatePhyiscs inside OnConstruction the collision does work as well.

If in BeginPlay, delayed, recreating the physics state of the extra collisions with RecreatePhysicsState(), it does work too.

@gurusaint the crash is happening because blueprint BeginPlay is called within Super::BeginPlay() in c++. At this point the wheels and the rest of the vehicle component are not yet initialized.

That is why a short delay works, as the vehicle is correctly initialized.

yes the camber sign is incorrect, thanks for pointing out.

when it comes to toe angle, the behavior is emergent, I mean there is no specific code about toe, we just rotate the wheels. anyway I’m gonna check the behavior when I get the time.

1 Like

yes it also collides with statics so I didn’t see any issues.

as long as the components are merged (there is an option called auto weld, on by default) applying forces to the body is not an issue.

yes, the bones aren’t there yet at beginplay.
anyway I will prevent the crash, thanks for pointing it out.

@lazybitgames Have a problem with erratic RPMs when accel/decel/brake.
Checked the cars in SandBox2 that have smooth RPMs but their behaviour is too slow.

This is the behaviour im looking, from rallycross cars in DirtRally 2.0.

They go up/down fast and smooth on accel/decel/brake.

What im using to smooth is:

Vehicle :: Drivetrain-Inertia (1.2-2.0)
// Default is 1. With 2 reduces Revs bounce after release brake
Engine :: FrictionTorque (280)
// Lower values = Less erratic Revs / But slower decrease
// Higher values = Car stops too soon on drop accel due engine brake
Engine :: Engine Inertia (0.6)
// Higher values = Less erratic Revs / But slower increase

What seems to fix is:

Transmission :: Clutch Power Scale ::
Value:1 = No erratic values, the smoothest/clean way.
Cons:
1 = Lot of time hitting limiter before upshift.
// Due gets max revs fast and has to wait for change gear up %.
2 = Braking has near to 0 effect.

I’ve been trying to do any kind of combinations but cant get exactly like that DR2.

One idea is use the “Stall Assist” code but for all gears + edits to manage the clutch scale modulation to all cases. But that can be time consuming to get all working as expected.

So, before that, is there any other param im missing to help achieve that RPM behaviour?
Played with gear ratios, final gear ratio, engine torque curves, clutch engagement sensivity/curve…

Hello @lazybitgames How can I get these HP numbers to put those values ​​in a widget text? Thanks.

i use the “calculate max power” but dont put the right numbers , the print string marks “211”

when in the engine its “283”

the result is in kilowatts, to convert to hp multipy with ~1.34

1 Like

engine rpm revs up and then wheel rpm is reflected back. as the rpm velocity increases the inaccuracies will be more observable. it’s difficult to make it smooth without changing behavior unless you increase the simulation frequency. if the driving behavior is ok for you then I recommend smoothing the visuals, you can do some averaging before showing it on screen.

note: clutch power scale was removed long time ago.

Sorry, removed when? Im using Unreal Engine 5.4.4 and FGear 1.8.2. and is there. In fact stall assist was added recently and it uses the Clutch Scale. When you said removed long time ago, when it was? I think im only one or two version behind right now.

But im editing and to get that smooth feeling, actually is a must. Well, if so i guess im gonna need to update to last to confirm all that removed/changed because then what im testing is for nothing.

Also is not about visual is how driving feels, with that the turns and overall feeling is more smooth.

yes I was confused, it’s not removed, sorry about that.

I removed it in my local version and will be removed in the next release since it’s an unrealistic parameter.

Then what about the stall assist (mClutchAssist) will be removed too?

Because it does like Clutch Power Scale, just instead of fixed, it modulates via RPM.

Is what im testing to smooth the RPMs in all scenarios. If it will be removed i will have to find another way, so confirm please.

I have reimplemented the stall assist and it works quite differently now.
if you go with that you won’t get what you want when you get the update.

I created a new project to check the v1.8.3 and the Stall Assist in Transsmission (mClutchAssist) have the same code than in 1.8.2. Maybe you have reimplemented a new stall assist locally too and will be available in a new update ¿? Or will be removed in future? Can you double check please.

To be clear this is what im talking about, this is the same in 1.8.2 and 1.8.3.

So, you gonna redo in a different way in a next update, or this stall assist and Clutch Power Scale will be removed in future versions? Is to be clear because now im more confused.

yes, i’m talking about my local changes. the stall assist will be different and clutch power scale will be gone in the following updates.
I haven’t decided on pushing one big update or splitting into smaller updates yet.