I am taking the “Unreal Engine C++ Developer” course and am on the BullCowGame section of the course. I changed my code, compiled it with no errors, but when I ran it I got the error in the title. The error stack it gives me is:
LoginId:ca9c85284291e4d7b997ada36ebdaf92
EpicAccountId:dc890ec830b84f35a90aebf4f79911e8
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000000000000e0
UE4Editor_BullCowGame_5144!UTerminal::PrintLine() [C:\Unreal Projects\BullCowGame-starter-kit\BullCowGame-starter-kit 4.27\Source\BullCowGame\Console\Terminal.cpp:47]
UE4Editor_BullCowGame_5144!UCartridge::PrintLine() [C:\Unreal Projects\BullCowGame-starter-kit\BullCowGame-starter-kit 4.27\Source\BullCowGame\Console\Cartridge.cpp:22]
UE4Editor_BullCowGame_5144!UBullCowCartridge::InitGame() [C:\Unreal Projects\BullCowGame-starter-kit\BullCowGame-starter-kit 4.27\Source\BullCowGame\BullCowCartridge.cpp:9]
UE4Editor_BullCowGame_5144!UBullCowCartridge::BeginPlay() [C:\Unreal Projects\BullCowGame-starter-kit\BullCowGame-starter-kit 4.27\Source\BullCowGame\BullCowCartridge.cpp:19]
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
kernel32
ntdll
The code I changed before the crash is this:
#include "BullCowCartridge.h"
void UBullCowCartridge::InitGame() {
lives = 4;
HiddenWord = TEXT("cake");
PrintLine(TEXT("Enter the hidden word, then press enter: ")); // I added this line here
bGameOver = false;
} // This is line 9.
void UBullCowCartridge::EndGame() {
ClearScreen();
bGameOver = true;
}
void UBullCowCartridge::BeginPlay() // When the game starts
{
InitGame(); // I added this function here
Super::BeginPlay(); // This is line 19.
}
void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
if (bGameOver == true || lives <= 0) {
ClearScreen(); //If the game is over, clear the screen and initilize again.
BeginPlay();
}
if (bGameOver == false) {
if (Input == HiddenWord) {
PrintLine(FString::Printf(TEXT("You have won.\nThe hidden word was indeed %s."), *HiddenWord));
bGameOver = true;
}
else if (lives <= 0) { // I added this else if statement.
PrintLine(TEXT("The game is over, press enter to play again."));
}
else {
PrintLine(TEXT("You have lost.\nHere is a clue, the word is actually %i letters long."), HiddenWord.Len());
--lives;
PrintLine(TEXT("The current number of lives you have left is %i."), lives);
}
}
}
I have the log file if you need it, I don’t know how to put it in here tho.