Help improving a Player within Actor bounds test

Hello UE4 community,

can anyone advise me on how I can improve my Player is within Actor Bounds test? I’m getting occasional Blueprint runtime errors when the Get Player Pawn evaluates to: None. This test is used to control doors on a dynamically resizing actor to prevent them locking while the player is on the wrong side.

Blueprint Runtime Error: Accessed None trying to read property CallFunc_GetPlayerPawn_ReturnValue from function: 'ExecuteUbergraph_A100001' from node: Set Player_Inside_Maze in graph: EventGraph in object: A100001 with description: Accessed None trying to read property CallFunc_GetPlayerPawn_ReturnValue

It still works as intended, but I don’t like having errors if I can avoid it. The none property appears to happen before gameplay actually starts. So I am guessing that it is happening in a brief moment before the player pawn exists. The boolean output is tested on an overlap event that (at the time) had not been triggered.

Any thoughts on how I might do this better or prevent that error being generated? Thanks in advance! :slight_smile:

Before checking your condition, you can check whether the Pawn is valid, like so:

But according to your condition, wouldn’t it be easier to use a volume for this check Volumes Reference | Unreal Engine Documentation?

Hi xSheim. Quite possibly.

I did it this way because the actor (a maze) I need to test is dynamically generated and resizes constantly during gameplay on a single level map.

In order to use a volume I’m assuming I’d need to match it to the Maze actors bounds (minus some padding) dynamically every time the maze’s re-generate function fires. It isn’t something I had considered or investigated. If I were to do it that way, there may be future use for a Nav Mesh Volume if that would work. I really have no idea how to use them yet though.

I’m pretty green. :wink:

Bam.

Adding an IsValid check on the Player Pawn has stopped the error. Thank you so much. :slight_smile: Now I can live with my (quite possibly terrible) inside bounds test!

Glad it helped. You can attach a volume to your actor (to detect overlaps you can use the Trigger Volume) and then dynamic resizing wouldn’t be a problem. But I think it would be a different-topic question. As for the Nav Mesh you mentioned, it could help: https://answers.unrealengine.com/questions/223395/dynamic-navigation-mesh.html