Fix long-standing crash when a vehicle is destroyed
This commit is contained in:
parent
c785437f08
commit
67643485cc
|
@ -91,7 +91,8 @@ void AWheeledVehicleAIController::Possess(APawn *aPawn)
|
|||
{
|
||||
Super::Possess(aPawn);
|
||||
|
||||
if (IsPossessingAVehicle()) {
|
||||
if (IsPossessingAVehicle())
|
||||
{
|
||||
UE_LOG(LogCarla, Error, TEXT("Controller already possessing a vehicle!"));
|
||||
return;
|
||||
}
|
||||
|
@ -108,13 +109,26 @@ void AWheeledVehicleAIController::Possess(APawn *aPawn)
|
|||
}
|
||||
}
|
||||
|
||||
void AWheeledVehicleAIController::UnPossess()
|
||||
{
|
||||
Super::UnPossess();
|
||||
|
||||
Vehicle = nullptr;
|
||||
}
|
||||
|
||||
void AWheeledVehicleAIController::Tick(const float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
if (!IsPossessingAVehicle())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TickAutopilotController();
|
||||
|
||||
if (bAutopilotEnabled) {
|
||||
if (bAutopilotEnabled)
|
||||
{
|
||||
Vehicle->ApplyVehicleControl(AutopilotControl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,9 +42,11 @@ public:
|
|||
/// @{
|
||||
public:
|
||||
|
||||
virtual void Possess(APawn *aPawn) override;
|
||||
void Possess(APawn *aPawn) override;
|
||||
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
void UnPossess() override;
|
||||
|
||||
void Tick(float DeltaTime) override;
|
||||
|
||||
/// @}
|
||||
// ===========================================================================
|
||||
|
|
Loading…
Reference in New Issue