Apparently Correct Object Reference No Longer Working

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.

I did some more experimenting. The initial cast is failing, but I have no idea why it suddenly started failing. It seems like for some reason the game isn’t spawning the default pawn, the camera pawn, anymore, and thus it doesn’t exist to be referenced, but I’ve rebuilt the project from the ground up and it still isn’t working, so I’m at a loss.

Things to check:

  1. Is the level definitely using this game mode? ( check project settings / world settings for the level )

  2. It could be a timing thing ( most likely from what you’re describing ). Put a delay before assigning the variable. It’s not the answer, but will let you know.

  3. Start the level, pop out with F8 and see if the pawn is actually in the level

  4. Last option: Manually put the correct kind of pawn in the level and try it.

Well, good you got there in the end…

I actually found the problem after a bit more messing around, and digging through other tangential answer pages. I set the pawn to spawn regardless of collision and it at least got things running, but the camera was stuck inside the sphere in the hierarchy that I’m using for visualization purposes. I don’t know what it is about the setup, and it’ll probably fix itself when I get around to finalizing it and don’t need a visual representation, but I think the pawn was basically colliding with itself on start (via the spring arm / camera’s interaction with the sphere), not spawning because it couldn’t resolve that collision, and thus nothing else worked. I unchecked Do Collision Test in Camera Collision on the spring arm, set the collision check back, and it works as intended now - with the obvious caveat that my camera now has no collision. I have no idea why it suddenly started doing this, or why it replicated across multiple unconnected projects. It tested out find at least a dozen times prior to this beginning. Easily one of the strangest things I’ve encountered in ue4 over the last couple years.