I am working on a project that requires a derived C++ PlayerController class. I am able to build the class with no issues in both 4.6.1 and 4.7, but if I open the blueprint in components, UE4 crashes.
I think there is something in my C++ code that the UE4 editor doesn’t like, since the other blueprints that do not use derived classes open fine for both graph and components.
The only thing that I see which might be missing would be some flags and the FObjectInitializer constructor. Here is a simple skeleton which works on my end:
UCLASS(Config = Game, BlueprintType, Blueprintable)
class AMyNewPC: public APlayerController
{
GENERATED_BODY()
public:
AMyNewPC(const FObjectInitializer& ObjectInitializer);
}
Updated project to 4.7.2, while I can open the PlayerController I get compilation errors. As soon as I resolve the compilation errors, UE4 crashes.
I’ve also attempted to remove all uses of the nodes, move the entire code to a C++ Function Library (see below), duplicating it and copying the entire PlayerController by hand, but UE4 still crashes with the same Access Violation error.
Good news, I’ve managed to get Player Controller to compile and show the Components Tab without crashing. The problem IS NOT in the C++ code. The issue is somewhere in this area of the blueprint:
Deleting the entirety of this somehow stopped UE4 from crashing upon compiling or showing the component tab. What it is supposed to do is move an element in the HUD to follow the mouse position, basically to act as a mouse cursor.
While this does crash in the components tab, this blueprint was able to compile and run with no issues in 4.6, do I have no idea what or why this part causes the access violation area and crash the engine.
As the components tab was removed in 4.7, do you get this crash when selecting the Viewport tab in your blueprint? If you create the same setup in a blueprint based on the default PlayerController class does that blueprint crash as well? Additionally, if you’ve narrowed the issue to the shown section of blueprint. I would try removing a couple nodes at a time to find out which node or combination of nodes is the cause.
Yes, it still crashed in 4.7 when selecting the Viewport tab. I’m going to try and narrow the issue now, I suspect it might be from calling the canvas in Player Controller.
Wrote this into the PlayerController, compiling it causes the Editor to Crash, so it must be either Set As Canvas Slot or Setting the Anchors of a Canvas Panel Slot that is causing the Access Violation.
The blueprint code above works fine without crashing when running inside the HUD itself.
Adding the Set Anchors node and Slot as Canvas Slot node to the PlayerController blueprint did not cause me to crash on compile. If you disconnect the other three nodes that lead into the Widget pin do you still crash on compile? How are those three nodes being used? The one labeled GameMode seems to be a variable but I’m not sure what the other two are doing.
Game Mode is a variable of an Object Blueprint
Main HUD is a variable inside Game Mode which stores the HUD blueprint.
Image Cursor is an image in the HUD.
To test this I greated a new blueprint for MyPlayerController, MyHUD, and MyGameMode. Inside the PlayerController I have a variable called GameModeRef that is of type MyGameMode. Inside MyGameMode I created a variable called MainHUD that is of type MyHUD. Inside of MyHUD I created a variable called Image of type Image. This allowed me to construct the setup you posted in your screenshot inside MyPlayerController which did not crash when I compiled it. Could you elaborate on how you set up your variables? Also, if you disconnect the nodes from the Slot as Canvas Slot input node do you still crash on compile?
We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.
Ah sorry, I did what you said earlier and despite not having the variables connected to Slot as Canvas slot, the editor still crashed.
However, I no longer use the blueprint nodes above in the PlayerController, doing the same in the MainHUD, where I can get the Image Cursor directly, doesn’t crash the editor.