Hello !
I’m using the save system for my game. In my save game class I store collectible IDs. The save is loaded from the gamemode’s BeginPlay method.
bool UMyGameInstance::LoadGameFromSlot(int SlotID, bool forceLoad)
{
if (!forceLoad && m_CurrentSaveGame != nullptr)
{
UE_LOG(LogTemp, Error, TEXT("LoadGameFromSlot: Attempt to load a game when another game is already loaded !"));
return false;
}
FString name;
if (GetSlotNameForSlotId(SlotID, name))
{
m_CurrentSaveSlotId = SlotID;
m_CurrentGameSaveSlotName = name;
if (UGameplayStatics::DoesSaveGameExist(name, 0))
m_CurrentSaveGame = Cast<UMySaveGame>(UGameplayStatics::LoadGameFromSlot(name, 0));
else
m_CurrentSaveGame = Cast<UMySaveGame>(UGameplayStatics::CreateSaveGameObject(UMySaveGame::StaticClass()));
m_CurrentSaveSlots->LastPlayedSlotId = m_CurrentSaveSlotId;
SaveSlots();
return true;
}
return false;
}
Here is my SaveGame class:
UCLASS()
class MYGAME_API UMySaveGame : public USaveGame
{
GENERATED_BODY()
public:
UMySaveGame();
virtual void BeginDestroy() override;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Basic)
TArray<int32> collectibles;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Basic)
int LastVisitedMapId = 0;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Basic)
int LastUnlockedMapId = 0;
};
I have then 2 different crashs that only occur on Android (never in editor).
- One from the a level where I list all collected collectibles. It crashes everytime the level starts.
- One when I break the object (In game) containing a collectible. This crash is really random. It works correcly most of the time.
For both cases it crashes at the exact same place, in a blueprint method where I get the CurrentGameSave and check it with a “IsValid” call. It crashes during the IsValid call! Here is the callstack I get from adb:
Script Stack:
BP_CollectibleActor_C.CheckActivation
BP_CollectibleActor_C.ActivateCollectible
BP_BreakableActor_C.ExecuteUbergraph_BP_BreakableActor
BP_BreakableActor_C.ReceiveHit[2017.10.03-15.24.47:579][
0]LogOutputDevice:Warning:Script Stack:
BP_CollectibleActor_C.CheckActivation
BP_CollectibleActor_C.ActivateCollectible
BP_BreakableActor_C.ExecuteUbergraph_BP_BreakableActor
BP_BreakableActor_C.ReceiveHitAssertion failed: Index >= 0 [File:Runtime/CoreUObject/Public\UObject/UObjectArray.h] [Line: 455]
libUE4.so!FDebug::LogAssertFailedMessage(char const*, char const*, int, wchar_t const*, …)
libUE4.so!UKismetSystemLibrary::execIsValid(FFrame&,
void)*
libUE4.so!UFunction::Invoke(UObject*,
FFrame&, void*)
libUE4.so!UObject::CallFunction(FFrame&,
void*, UFunction*)
libUE4.so!UObject::ProcessContextOpcode(FFrame&,
void*, bool)
libUE4.so!UObject::execLetBool(FFrame&,
void*)
libUE4.so!UObject::ProcessInternal(FFrame&, void*)
libUE4.so!UObject::CallFunction(FFrame&,
void*, UFunction*)
libUE4.so!UObject::ProcessInternal(FFrame&, void*)
libUE4.so!UObject::CallFunction(FFrame&,
void*, UFunction*)
libUE4.so!UObject::ProcessContextOpcode(FFrame&,
void*, bool)
libUE4.so!UObject::ProcessInternal(FFrame&, void*)
libUE4.so!UObject::CallFunction(FFrame&,
void*, UFunction*)
libUE4.so!UObject::ProcessInternal(FFrame&, void*)
libUE4.so!UFunction::Invoke(UObject*,
FFrame&, void*)
libUE4.so!UObject::ProcessEvent(UFunction*, void*)
libUE4.so!AActor::ReceiveHit(UPrimitiveComponent*,
AActor*, UPrimitiveComponent*, bool,
FVector, FVector, FVector, FHitResult
const&)
I really don’t understand why it crashes, if you need more info, let me know !