TL;DR A reference that was previously working in a project has stopped working, despite no changes having been made aside from saving all assets and restarting the computer / editor.
I’ve spent a few hours over the last couple days working on a top down camera for a CRPG/RTS style project, and fiddling with a few things in my free time. Yesterday I hit a point where I could control the basic movements of my camera pawn with WASD and rotate around its Z axis, but stopped after figuring out the solution for the mouse input weirdness when you’re showing the mouse on screen. Basically I needed to set Input Mode to Game And UI instead of Game Only. Everything worked, including the mouse input, I click save all and go to sleep.
Boot the project back up this morning, don’t touch anything, hit play and suddenly the editor is returning none for the reference in the player controller script that holds the pawn with the camera in it. I no long control anything when I click play, the engine’s default camera simply spawns at the player start and that’s it.
Blueprint Runtime Error: “Accessed None”. Blueprint: BP_CameraRig Function: Movement Speed Calculation Graph: MovementSpeedCalculation Node: Return Node
Blueprint Runtime Error: “Accessed None trying to read property CameraPawnRef”. Blueprint: BP_CameraRig Function: Execute Ubergraph BP Camera Rig Graph: EventGraph Node: SetActorTransform
Here’s the Camera Pawn Ref variable’s settings:
On play I cast to the default player pawn, which is set as BP_CameraPawn in the default game mode, to make sure it’s the default pawn and set the variable. This is handled in a macro so that I can add more reference casts without cluttering up the event graph.
I then reference elements of it to determine things. Like in this small calculation to alter the camera’s movement speed depending on camera zoom, which is one of the things throwing an error.
Beyond that, obviously just setting transforms at this point. Not even anything refined, just press the button and change position type stuff. It’s as basic as basic can be.
So I start trying to fix this. Make sure the name is right, it is. Make sure the game mode sets BP_CameraPawn as the default pawn class, it does.
Check that nothing got changed in BP_CameraPawn, none of it has been. Only difference from exactly what you’d start with is that it has the SpringArm object’s camera Lag settings enabled and Target Arm Length increased, otherwise it’s a pawn with a Scene > Sphere > SpringArm > Camera hierarchy added to it and nothing else. Just a dummy container so that the camera can be separated from the actual character in the game. There’s no blueprint in it at the moment.
I even tried remaking the variable, and replacing the handful of points at which it’s referenced with the new one. No dice. Same error every time. Problem is, I can’t find anything that’s changed since it was working last night, and I can’t find anything wrong with what I’m doing - because again it’s the same as it was when it was working previously.