Uninitialized local variable error that I cannot fix

Not sure if this is related to issue, but you set variable before you declare it which normally compiler should give you error

PVehicleDrive = nullptr;
PxVehicleDrive4W* PVehicleDrive = PxVehicleDrive4W::allocate(4);

It should look like this, theres no need to set it to nullptr if you set it below anyway.

PxVehicleDrive4W* PVehicleDrive;
PVehicleDrive = PxVehicleDrive4W::allocate(4);

If you have linking error it means you might missing something in build script (*.cs files), so look it up

I have been having some issues while making a custom vehicle class, it inherits from “WheeledVehicleMovementComponent.h”, I have the intent of later making it use more than 4 wheels. But for now I just want to make it a simpler version of the 4W version so I can at least test it. The current code is essentially a stripped version of “WheeledVehicleMovementComponent4W”.

I will post the part that is giving trouble. (Not sure how code is supposed to be posted here)

// Create the vehicle
	PVehicleDrive = nullptr;
	/*PvehicleDrive is not initialized yet, even though the line below assings something to it*/
	PxVehicleDrive4W* PVehicleDrive = PxVehicleDrive4W::allocate(4); /*PVehicleDrive used to be PVehicleDrive4W*/
	check(PVehicleDrive);

	ExecuteOnPxRigidDynamicReadWrite(UpdatedPrimitive->GetBodyInstance(), [&](PxRigidDynamic* PRigidDynamic)
	{
		PVehicleDrive->setup(GPhysXSDK, PRigidDynamic, *PWheelsSimData, DriveData, 0);
		PVehicleDrive->setToRestState();

		// cleanup
		PWheelsSimData->free();
	});

PVehicleDrive is the Uninitialized variable, I am unsure as to how I should initialize it. I am going to describe my findings and what I have tried to fix this error, might just be a simple oversight by me.

“WheeledVehicleMovementComponent4W” uses it’s own “PVehicleDrive4W”, but I cannot find where it is defined with VS, so it has to be in “WheeledVehicleMovementComponent4W.cpp” itself. However it isn’t initialized before “PxVehicleDrive4W* PVehicleDrive = PxVehicleDrive4W::allocate(4);”. Using “PVehicleDrive4W” in my code generates a “LNK2019 unresolved external symbol” error.

Considering how the 4W class, and an old plugin that adds multi wheel capability “NWheel” both use their own “PVehicleDrive4W” and “PVehicleDriveNW” variables, I though that I could use my own. However using anything but “PVehicleDrive” gives me the LNK2019 error that I cannot find any documentation on.

I forgot to remove that line, adding it has no effect.

The default 4W class looks like this:

// Create the vehicle
	PxVehicleDrive4W* PVehicleDrive4W = PxVehicleDrive4W::allocate(4);
	check(PVehicleDrive4W);

	ExecuteOnPxRigidDynamicReadWrite(UpdatedPrimitive->GetBodyInstance(), [&] (PxRigidDynamic* PRigidDynamic)
	{
		PVehicleDrive4W->setup( GPhysXSDK, PRigidDynamic, *PWheelsSimData, DriveData, 0);
		PVehicleDrive4W->setToRestState();

		// cleanup
		PWheelsSimData->free();
	});

Adding PxVehicleDrive4W* PVehicleDrive; gives a new error.
Error C2086 ‘physx::PxVehicleDrive4W *PVehicleDrive’: redefinition

This is the dilemma, I know PVehicleDrive is defined in the class I am inheriting, however using anything else gives me the LNK2019 error. So far I have tried adding “Physx” and “APEX” into my build.cs file, however that didn’t fix the LNK error. I even added “PhysicsPublic.h” and “PhysXPublic.h” to my project header file.

Could I be missing even more includes? Or could I just use PVehicleDrive still.

I also noticed this error.
Error MSB3073 The command ““C:\Program Files\Epic Games\UE_4.15\Engine\Build\BatchFiles\Rebuild.bat” peliEditor Win64 Development “E:…peli.uproject” -waitmutex” exited with code -1. peli C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets 46

I am pretty sure I have everything set up properly, and i think this is just an error caused by the failed compile, but could this be worth noting?

I am still wondering where the default 4W class defines PVehicleDrive4W, VS could not find it, it should not even be out side of WheeledVehicleMovementComponent4W .cpp and/or .h.