LNK2019: unresolved external symbol "class physx::PxScene * __cdecl GetPhysXSceneFromIndex(int)"

Hello, I am subclassing UWheeledVehicleMovementComponent4W but I can not successfuly override this function:

UWheeledVehicleMovementComponent.h


virtual void SetupWheels(physx::PxVehicleWheelsSimData* PWheelsSimData);

is my code:

.h


void SetupWheels(physx::PxVehicleWheelsSimData* PWheelsSimData) override;
 
.cpp (#include "PhysXPublic.h")

 void UUnsealedWheeledVehicleMovComp4W::SetupWheels(PxVehicleWheelsSimData* PWheelsSimData)
 {
     if (!UpdatedPrimitive)
     {
         return;
     }
 
     ExecuteOnPxRigidDynamicReadWrite(UpdatedPrimitive->GetBodyInstance(), &](PxRigidDynamic* PVehicleActor)
     {
         
     });
 }

Build file:


 PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "PhysX", "APEX" });
 
         PrivateDependencyModuleNames.AddRange(new string] {  });
 
         Definitions.Add("WITH_PHYSX=1");

Error:


 1>UnsealedWheeledVehicleMovComp4W.cpp.obj : error LNK2019: unresolved external symbol "class physx::PxScene * __cdecl GetPhysXSceneFromIndex(int)" (?GetPhysXSceneFromIndex@@YAPEAVPxScene@physx@@H@Z) referenced in function "public: static bool __cdecl FPhysXSupport<1>::ExecuteOnPxRigidDynamicReadWrite<class <lambda_fbc31c33d8fac28ca36dd3b4b0518bd6> >(struct FBodyInstance const *,class <lambda_fbc31c33d8fac28ca36dd3b4b0518bd6> const &)" (??$ExecuteOnPxRigidDynamicReadWrite@V<lambda_fbc31c33d8fac28ca36dd3b4b0518bd6>@@@?$FPhysXSupport@$00@@SA_NPEBUFBodyInstance@@AEBV<lambda_fbc31c33d8fac28ca36dd3b4b0518bd6>@@@Z)

I cleaned code and found out that this line is causing issue: ExecuteOnPxRigidDynamicReadWrite(UpdatedPrimitive->GetBodyInstance(), &](PxRigidDynamic* PVehicleActor)

Did you ?


#include "PhysXIncludes.h"

And


//For the ptou conversions
//Pre 4.9
//#include "PhysicsPublic.h"  
 
//4.9 onward
#include "PhysXPublic.h"

You also want to check out the Wiki wrote .

Thank you, but I did everything right using that arctile, these are my includes:


#include "PhysXPublic.h"
#include "Runtime/Engine/Private/PhysicsEngine/PhysXSupport.h"
#include "PhysXIncludes.h"

PhysX functions work great but there is something special needed for this one probably

Solved, is solution: Linker error in Editor builds using ExecuteOnPxRigidDynamicReadWrite - World Creation - Epic Developer Community Forums

Great !
Checked out the answer, can you please explain to me what you are doing ?
Or is it just a typo?


BodyInstance->ExecuteOnPhysicsReadWrite(**&**]

Not it is not typo but:

will get deeper into it when there will be some time, right now I am not sure what is does… I needed to override one or two lines of original function so I just used Epic’s code and updated a few lines.

Look up C++11 Lambda Functions.