Dynamic Skeletal Mesh for Vehicles

I’m creating a game where there will be 50 or more traffic cars. So I created a single blueprint for vehicle where a random skeletal mesh is chosen from those 50 cars. And I got stuck even at first task. I am facing these problems in various scenarios:

  1. If I don’t define any Skeletal Mesh in Main Mesh. The Vehicle Movement thing isn’t initialized at all. That means the Wheels data etc everything is not working at all.

  2. If I define Car1 in Mesh and upon choosing the random whenever it choses Car1 it works fine but whenever it choses Car2…Car50 UE crashes. and here’s the bug report:

    physx::PxVehicleUpdate::updatePost(physx::PxVehicleConcurrentUpdateData const*, unsigned int, physx::PxVehicleWheels**) Address = 0x10497e96f (filename not found) [in UE4Editor-Engine.dylib] physx::PxVehicleUpdate::updateDrive4W(float, physx::PxVec3 const&, float, float, physx::PxVehicleDrivableSurfaceToTireFrictionPairs const&, physx::PxVehicleDrive4W*, physx::PxVehicleWheelQueryResult*, physx::PxVehicleConcurrentUpdateData*) Address = 0x104973ab5 (filename not found) [in UE4Editor-Engine.dylib] physx::PxVehicleUpdate::update(float, physx::PxVec3 const&, physx::PxVehicleDrivableSurfaceToTireFrictionPairs const&, unsigned int, physx::PxVehicleWheels**, physx::PxVehicleWheelQueryResult*, physx::PxVehicleConcurrentUpdateData*) Address = 0x10497e4de (filename not found) [in UE4Editor-Engine.dylib] physx::PxVehicleUpdates(float, physx::PxVec3 const&, physx::PxVehicleDrivableSurfaceToTireFrictionPairs const&, unsigned int, physx::PxVehicleWheels**, physx::PxVehicleWheelQueryResult*, physx::PxVehicleConcurrentUpdateData*) Address = 0x10497ea92 (filename not found) [in UE4Editor-Engine.dylib] FPhysXVehicleManager::UpdateVehicles(float) Address = 0x1063a4343 (filename not found) [in UE4Editor-Engine.dylib] FPhysXVehicleManager::Update(float) Address = 0x1063a3b86 (filename not found) [in UE4Editor-Engine.dylib] FPhysSubstepTask::SubstepSimulationStart() Address = 0x106267d41 (filename not found) [in UE4Editor-Engine.dylib] FPhysSubstepTask::SubstepSimulationEnd(ENamedThreads::Type, TRefCountPtr const&) Address = 0x106268fec (filename not found) [in UE4Editor-Engine.dylib] TBaseRawMethodDelegateInstance<false, FPhysSubstepTask, void (ENamedThreads::Type, TRefCountPtr const&)>::ExecuteIfSafe(ENamedThreads::Type, TRefCountPtr const&) const Address = 0x106279822 (filename not found) [in UE4Editor-Engine.dylib] TGraphTask::ExecuteTask(TArray&, ENamedThreads::Type) Address = 0x10524f8fc (filename not found) [in UE4Editor-Engine.dylib] FTaskThread::ProcessTasks(int, bool) Address = 0x10382780a (filename not found) [in UE4Editor-Core.dylib] FTaskThread::ProcessTasksUntilQuit(int) Address = 0x103826a05 (filename not found) [in UE4Editor-Core.dylib] FTaskThread::Run() Address = 0x10382966b (filename not found) [in UE4Editor-Core.dylib] FRunnableThreadPThread::Run() Address = 0x1038352fd (filename not found) [in UE4Editor-Core.dylib] FRunnableThreadPThread::_ThreadProc(void*) Address = 0x10381d08c (filename not found) [in UE4Editor-Core.dylib] _pthread_body Address = 0x7fff833a2268 (filename not found) [in libsystem_pthread.dylib] _pthread_body Address = 0x7fff833a21e5 (filename not found) [in libsystem_pthread.dylib] thread_start Address = 0x7fff833a041d (filename not found) [in libsystem_pthread.dylib]

I’ve tried various techniques doing this thing with C++ as well, but the result is same.

I also tried the same thing on ThirdPerson game character and it worked absolutely fine. Is there anything I am missing, maybe reinitialising the VehicleMovementComponent or so. I’m not sure.

Is it a bug or am I missing something here? Please help.

Hello akashkamboj,

I would suggest using a different blueprint/VehicleMovementComponent for each of these cars instead of swapping out the skeletal meshes. The reason for this is due to the VehicleMovementComponent being the part that controls the wheel size, the torque settings and all things related to vehicles. If you were to swap skeletal meshes on the fly using the same settings, all cars would only be visually different and cars with larger wheels would seem to sink into the ground.

That said, I’ll look into what could be done to allow switching skeletal meshes on the fly and see what I come up with.