Download

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);

Here 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 Rama wrote here.

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, here is solution: https://answers.unrealengine.com/questions/257161/linker-error-in-editor-builds-using-executeonpxrig.html?sort=oldest

Great !
Checked out the answer, can you please explain to me what you are doing here?
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.