How to access a private class?

Hi again,

I’m trying to access FPhysXVehicleManager class from my plugin module, but I can’t call any method of it without get an unserolved external symbol…

I know it is a private engine class, and there is no way to access it with a custom module? Even a Engine Module can’t access it?

Thx anyway

Hello edsonsantoro,

Depending on where you’re trying to gain access to the FPhysXVehicleManager, you should be able to easily get a reference to it from the PhysicsScene. This is also easily accessible from the current world.

For example, if you’re trying to get a reference to FPhysXVehicleManager from inside an AActor:

FPhysXVehicleManager* MyDerivedAActorClass::GetPhsyXVehicleManager()
{
    UWorld* World = AActor::GetWorld();
    if (World)
    {
        FPhysScene* PhysicsScene = World->GetPhysicsScene();
        if (PhysicsScene)
        {
            return PhysicsScene->GetVehicleManager();
        }
    }
    return nullptr;
}

However, for this to work properly, the project must be set to compile with PhysX (which is true by default).

Thanks,
Jon N.

Thank you Jon, and sorry for the lack of information on the question…

I’m trying to access it from a UVehicleWheel derived class that I made, called UMyVehicleWheel, for instance. I’ve noticed that this class do exactly what you explained here, it gets the VehicleManager class through vehicle, and it work like a charm on base class, but doing so in my derived class, wich is an engine plugin, ends in a unresolved external symbol.

Although, I’m starting to think that it has something related to how I’m calling the vehicle manager in my custom class… Wich is exactly the same as base class.

To be honest, I’m not too familiar with working with plugins, but that might be part of the problem. Unresolved external symbol errors are caused when the linker can’t find definitions for the item you’re trying to reference.

So, the problem might be that your plugin can’t find the DLL where the definitions for that class are.

I’ll try to investigate this a little more, and let you know what I find.

I’m still getting the same error, can you please take a look?! ^^!

UVehicleWheelWithCamber is my derived class from UVehicleWheel.
GetWheelRotationAngles is a plain UFunction.

FQuat UVehicleWheelWithCamber::GetWheelRotationAngles()
{
#if WITH_VEHICLE

	UWorld* World = UVehicleWheelWithCamber::GetWorld();
	FPhysXVehicleManager* VehicleManager;

	if (World)
	{
		FPhysScene* PhysicsScene = World->GetPhysicsScene();
		if (PhysicsScene)
		{

			VehicleManager = PhysicsScene->GetVehicleManager();

		}
	}
	FQuat zeros;
	//	PxTransform PxPose = VehicleManager->GetWheelsStates_AssumesLocked(VehicleSim)[WheelIndex].localPose;
	//	FQuat LocalPose(PxPose.q.x, PxPose.q.y, PxPose.q.z, PxPose.q.w);
	return zeros;
#else
	return zeros;
#endif //WITH_PHYSX

}

And I got this:

Error	1	error LNK2019: unresolved external symbol "public: class FPhysXVehicleManager * __cdecl FPhysScene::GetVehicleManager(void)" (?GetVehicleManager@FPhysScene@@QEAAPEAVFPhysXVehicleManager@@XZ) referenced in function "public: struct FQuat __cdecl UVehicleWheelWithCamber::GetWheelRotationAngles(void)" (?GetWheelRotationAngles@UVehicleWheelWithCamber@@QEAA?AUFQuat@@XZ)	D:\Git\UnrealEngine4.11\Engine\Intermediate\ProjectFiles\Module.NWheeledVehicles.cpp.obj	UE4

Thank you very much! I’m glad to see that my efforts are not in vain !!!

Well, after some review I think this might be an issue with how your plugin is configured. Can you look in your Plugin’s source directory for something call (or named along the lines): Plugin.Build.cs.

Could you upload that file (or at least a snapshot of it)?

Here it is!

I’ve changed the extension to txt, because I couldn’t upload *.cs … jt display an error message that it is not possible to upload a unknown file type…

link text

I have added several relative paths trying to resolve the problem, so, please, just ignore that.

I’m sorry but, may I ask if you have found something?! ^^\

I was able to reproduce the issue you’re having, and am looking into the issue now.

So, I have found a workaround for this issue. However, I’m not sure if the original designer intentionally made it so this function could not be directly accessed by users, or if it was by mistake.

Given the lack of documentation for the FPhysXVehicleManager class and that it’s source is in a private directory, it’s more than likely that you are not supposed to directly access this class.

If you can give me some insight into what you’re trying to achieve, maybe there’s a better way to go about it that I can help you find that is supported.

In my plugin, I’m exposing various PhysX properties that is not yet available in UE4. One of those is wheel camber. I could successfully extend the vehicle wheel class to add those properties. Now, to animate these wheels with camber movement I need to change how the AnimNode_WheelHandler class queries these information. At the moment it “asks” for wheel rotation angle and steer angle, but for roll, it is hard coded to 0.0. With PhysXVehicleManager, I would be able to get localPose property from the struct PxWheelQueryResult, witch stores a quaternion with all wheel angles. I don’t know other way to do this.

Well, you could just expose the API so you can use it. That’s the nice thing about having the source available…

If you wanted to do that, it’s actually quite simple, just edit the PhysicsPublic.h file to include ENGINE_API in front of the method declaration.

It would look something like this:
(Engine\Source\Runtime\Engine\Public\PhysicsPublic.h ~ Line: 376):

ENGINE_API FPhysXVehicleManager* GetVehicleManager();

However, since your developing a plugin, I’d strongly advise against this. Anyone who would use your plugin would had to have made the same modifications. Further, this may have been explicitly been omitted so users could not have access for one reason or another.

Ah ok, thank you for your help. Very appreciated.

You have found a solution? I have the same problem. :frowning:

I’m in my holidays now, but I’ve found something that may work on this question: https://answers.unrealengine.com/questions/257161/linker-error-in-editor-builds-using-executeonpxrig.html

I’ve noticed that other classes like WheeledVehicleMovementComponent call various functions of PhysX throught ExecuteOnPxRigidDynamicReadWrite, so it may be usefull for us…I think

As is simple solution for realtime update , i use VehicleSetupTag++ , example (in child class from UVehicleMovementComponent4W):
// …
Mass = 5000;
VehicleSetupTag++;
// …

Or try use PhysX functions , for set mass , or wheels radius/width and etc. But not sure what that will be working for all what u want :frowning:

PS: sorry for english

Didn’t know about that…
I’ll look at it too when I get back from holidays

InuHitman,

See the answer below. I’ll let edsonsantoro un-mark it as a solution if he doesn’t think it will suit his purposes.

Thanks,
Jon N.

Actually, for me it doesn’t work, but may be useful for someone. I’ll look into different ways to achieve this.