FGear Vehicle Physics (v1.4)

there is no change in input code since last year.

looking at your video there seems to be some interference with your input, it’s visible at around 13.-14. second. the steering bar at the bottom twitches before moving to the left. I suggest unplugging other input devices and try again with the keyboard.

Trying to achieve that on reverse, if press accel = wheels starts spinning forward, without reduction to 0 first.

It seems the problem is at: UFGearWheel::updateWheelSpeed on //ground correction, if (mHasContact).

Because doing some changes i get that fixed, but then, the overall accel/braking not works as previous.

Any idea? Or maybe there is another way to fix that better?

EDIT: What im trying inside (mHasContact is:
if (groundDelta < 0.0f && mVehicle->getEngine()->getThrottle() > 0.0f)
= Spin the wheels
else = as original

that portion of the code is critical and easy to brake, so be careful.

can you try setting “Optimum Slip Weight” to 1.0 after making that fix.

the acceleration/braking behavior is mostly tied on wheel slip and using this param will make sure you get an optimal value at all times.

All should get fixed without edit “Optimum Slip Weight”, i just want avoid that reduction on reverse, rest the same. Im gonna sleep now, tomorrow i will try with an else if and clone the code, so when reverse + accel will try to change or avoid some code will see.

I think got it, let me know what you think:

  1. Changed condition to use getStandardInput()->getThrottleRawInput()
    Because with previous one also triggers on braking-reverse.

  2. Using getKMHSpeed() < 0.0f, instead of groundDelta.

  3. After some debug and testing seems this does what i was looking:
    bool caseFIX = getKMHSpeed() < -0.1f && mVehicle->getStandardInput()->getThrottleRawInput() > 0.0f;
    mRealSpeed += caseFIX ? 1.0f : deltaV;

Still playing around and testing all scenarios but after some hours no weird behaviours found.

@lazybitgames , can you please share some insight on how you pooled the vehicles? I am having consitent crashes. I need to pool my vehicles as spawning a lot of vehicles and destroying them tanks my perf.


I have attached my pooling and depooling functions. Sleep is called when entering the pool. Pooling function is bound to Sleep delegate. This works fine. The problem is exiting the pool. I can calling the depooling function before waking the vehicle and I get this crash

Assertion failed: ProxyBaseIn->GetMarkedDeleted() == false [File:D:\build++UE5\Sync\Engine\Source\Runtime\Experimental\Chaos\Public\Chaos\Framework\PhysicsSolverBase.h] [Line: 330]

UnrealEditor_Core!FDebug::CheckVerifyFailedImpl2() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:728]
UnrealEditor_PhysicsCore!Chaos::FPhysicsSolverBase::AddDirtyProxy() [D:\build++UE5\Sync\Engine\Source\Runtime\Experimental\Chaos\Public\Chaos\Framework\PhysicsSolverBase.h:330]
UnrealEditor_PhysicsCore!Chaos::FRigidBodyHandle_External::SetV() [D:\build++UE5\Sync\Engine\Source\Runtime\Experimental\Chaos\Public\PhysicsProxy\SingleParticlePhysicsProxy.h:1173]
UnrealEditor_PhysicsCore!FChaosEngineInterface::SetLinearVelocity_AssumesLocked() [D:\build++UE5\Sync\Engine\Source\Runtime\PhysicsCore\Private\ChaosEngineInterface.cpp:633]
UnrealEditor_Engine!Chaos::TAABBTree<int,Chaos::TAABBTreeLeafArray<int,1,double>,1,double,Chaos::TDefaultAABBTreeStorageTraits<int> >::ProgressCopyTimeSliced'::2’::<lambda_1>::operator()() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\PhysicsEngine\BodyInstance.cpp:3562]
UnrealEditor_Engine!FBodyInstance::SetLinearVelocity() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\PhysicsEngine\BodyInstance.cpp:3549]
UnrealEditor_FGearPlugin!AFGearVehicle::handleWakeUp() [D:\build\U5M\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\FGearPlugin\Source\FGearPlugin\Private\FGearVehicle.cpp:1531]
UnrealEditor_CoreUObject!UFunction::Invoke() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:7453]
UnrealEditor_CoreUObject!UObject::CallFunction() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1175]
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:7453]
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_MassActors!UMassActorSpawnerSubsystem::SpawnOrRetrieveFromPool() [D:\build++UE5\Sync\Engine\Plugins\Runtime\MassGameplay\Source\MassActors\Private\MassActorSpawnerSubsystem.cpp:245]
UnrealEditor_MassActors!UMassActorSpawnerSubsystem::ProcessSpawnRequest() [D:\build++UE5\Sync\Engine\Plugins\Runtime\MassGameplay\Source\MassActors\Private\MassActorSpawnerSubsystem.cpp:399]
UnrealEditor_MassActors!UMassActorSpawnerSubsystem::ProcessPendingSpawningRequest() [D:\build++UE5\Sync\Engine\Plugins\Runtime\MassGameplay\Source\MassActors\Private\MassActorSpawnerSubsystem.cpp:364]
UnrealEditor_MassActors!UMassActorSpawnerSubsystem::OnPrePhysicsPhaseStarted() [D:\build++UE5\Sync\Engine\Plugins\Runtime\MassGameplay\Source\MassActors\Private\MassActorSpawnerSubsystem.cpp:513]
UnrealEditor_MassActors!V::TBaseUObjectMethodDelegateInstance::ExecuteIfSafe() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:689]
UnrealEditor_MassEntity!TMulticastDelegate<void __cdecl(float),FDefaultDelegateUserPolicy>::Broadcast() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl:1080]
UnrealEditor_MassEntity!FMassProcessingPhase::ExecuteTick() [D:\build++UE5\Sync\Engine\Source\Runtime\MassEntity\Private\MassProcessingPhaseManager.cpp:74]
UnrealEditor_Engine!TGraphTask::ExecuteTask() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:706]
UnrealEditor_Core!UE::Tasks::Private::FTaskBase::TryExecuteTask() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Tasks\TaskPrivate.h:527]
UnrealEditor_Core!FNamedTaskThread::ProcessTasksNamedThread() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:779]
UnrealEditor_Core!FNamedTaskThread::ProcessTasksUntilIdle() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:679]
UnrealEditor_Core!FTaskGraphCompatibilityImplementation::ProcessUntilTasksComplete() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:1592]
UnrealEditor_Engine!FTickTaskSequencer::ReleaseTickGroup() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:986]
UnrealEditor_Engine!FTickTaskManager::RunTickGroup() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:2079]
UnrealEditor_Engine!UWorld::RunTickGroup() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:786]
UnrealEditor_Engine!UWorld::Tick() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1511]
UnrealEditor_UnrealEd!UEditorEngine::Tick() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:2151]
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
ntdll

it looks like somehow your physics body is marked to be deleted, idk how that happened though, I tried a similar BP code and didn’t encounter such a problem.

on the other hand my approach to actor activation/deactivation was rather simple, sth. like below code:

void setActorActive(AActor* actor, bool active)
{
	//set actor states
	actor->SetActorHiddenInGame(!active);
	actor->SetActorEnableCollision(active);
	actor->SetActorTickEnabled(active);

	//set component tick states
	TInlineComponentArray<UActorComponent*> components;
	actor->GetComponents(components);
	for (int i = 0; i < components.Num(); i++) 
	{ 
		components[i]->SetComponentTickEnabled(active);
	}

	//...
}

@lazybitgames How do you handle the suspension not being reinstated when reactivating the actor?

Because upon reactivating, the wheels fall through the ground

maybe try calling vehicle.reset before reactivating.