Hello, I’d like to know if there’s a way to crash the game in C++ on purpose. Not closing the game or exiting from it, straight up crashing the game.
What is your desired crash result? I.e. ‘Not Responding’, or more of a soft crash where the game still runs but nothing works in the game (so a simulated crash where you just take control away from the player and everything could appear to freeze)
Also why, out of interest, if its the former option?
Presumably you’re talking about Assertions.
UE has it’s own flavours:
for (i=0; i<100000000000; i++) {
}
// Infinite loop detected
Just use an invalid pointer?
If you want to test the Crash Reporter, you can execute the command debug crash
. It’s probably more expressive and legible than writing C++ code that deliberately crashes.
A UE_LOG using Fatal verbosity will also “crash” the engine.
Nearly all of those answers crash the game, but I think the best and efficent way of doing this would be executing the command ‘debug crash’ as KristofMorva said, thanks for all the answers!
I worked on a project who’s crash server command was:
PlayerController = nullptr;
PlayerController.SetGodMode(true);