Skip to content

Commit

Permalink
Fix crash when launching cooked environment created with SUV vehicle.
Browse files Browse the repository at this point in the history
  • Loading branch information
lovettchris committed Apr 5, 2018
1 parent 4d02910 commit 87f0797
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
24 changes: 13 additions & 11 deletions Unreal/Plugins/AirSim/Source/Car/CarPawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ ACarPawn::ACarPawn()

UWheeledVehicleMovementComponent4W* Vehicle4W = CastChecked<UWheeledVehicleMovementComponent4W>(GetVehicleMovement());

// load assets
if (UseDefaultMesh) {
static MeshContructionHelpers helpers(AirSimSettings::singleton().car_mesh_paths);
GetMesh()->SetSkeletalMesh(helpers.skeleton);
GetMesh()->SetAnimationMode(EAnimationMode::AnimationBlueprint);
GetMesh()->SetAnimInstanceClass(helpers.bp->GeneratedClass);
SlipperyMaterial = helpers.slippery_mat;
NonSlipperyMaterial = helpers.non_slippery_mat;
}

static ConstructorHelpers::FClassFinder<APIPCamera> pip_camera_class(TEXT("Blueprint'/AirSim/Blueprints/BP_PIPCamera'"));
pip_camera_class_ = pip_camera_class.Succeeded() ? pip_camera_class.Class : nullptr;

check(Vehicle4W->WheelSetups.Num() == 4);

// Wheels/Tyres
Expand Down Expand Up @@ -165,17 +178,6 @@ void ACarPawn::initializeForBeginPlay(bool enable_rpc, const std::string& api_se
else
EngineSoundComponent->Deactivate();

// load assets
MeshContructionHelpers helpers(AirSimSettings::singleton().car_mesh_paths);
GetMesh()->SetSkeletalMesh(helpers.skeleton);
GetMesh()->SetAnimationMode(EAnimationMode::AnimationBlueprint);
GetMesh()->SetAnimInstanceClass(helpers.bp->GeneratedClass);
SlipperyMaterial = helpers.slippery_mat;
NonSlipperyMaterial = helpers.non_slippery_mat;

ConstructorHelpers::FClassFinder<APIPCamera> pip_camera_class(TEXT("Blueprint'/AirSim/Blueprints/BP_PIPCamera'"));
pip_camera_class_ = pip_camera_class.Succeeded() ? pip_camera_class.Class : nullptr;

//put camera little bit above vehicle
FTransform camera_transform(FVector::ZeroVector);
FActorSpawnParameters camera_spawn_params;
Expand Down
5 changes: 5 additions & 0 deletions Unreal/Plugins/AirSim/Source/Car/CarPawn.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class ACarPawn : public AWheeledVehicle
UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
UAudioComponent* EngineSoundComponent;


/** Whether to load the default meshes */
UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
bool UseDefaultMesh = false;

public:
ACarPawn();

Expand Down

0 comments on commit 87f0797

Please sign in to comment.