Editor Crash with specific code

Hi all,

Here is the code that crashes the editor:

ATOA_Weapon* wpn = (ATOA_Weapon*)GetWorld()->SpawnActor(ATOA_Weapon::StaticClass());

I can compile in VS2015 Community without problems or errors, but as soon as i switch back to the editor it crashes with “Fatal Error!” popup window. When i try to start the editor again i get the same error. If i comment out that line, the editor starts right up. Is there something wrong with that line of code? What’s going on here?


In Unreal all forms of typecasting is done like this, instead of the C++ syntax:

ATOA_Weapon* wpn = Cast<ATOA_Weapon>(GetWorld()->SpawnActor(ATOA_Weapon::StaticClass()));

I think that may solve the issue.

I changed the cast, but that did not solve the issue.
After reading similar posts on the forum i deleted the Binaries, Intermediate and Saved folders from the project in explorer. That seamed to fix the problem. The editor starts now even though some of the input mappings are gone… not sure what else is missing but at least the editor is running again.

I don’t think this problem was caused by my code. I think it was something to do with the files in those folders. Corruption maybe?