Blueprint Communication - Accessed None

Hey, I have a blueprint with multiple components, and when the player clicks on one of these components it sets an integer variable relative to the component clicked. This works fine. I have a second blueprint that changes its properties based on the value of an integer. This also works fine. The issue comes when I try to retrieve the integer variable from the first blueprint (the target) in the second blueprint (the working). Below you can see my function that does this, however, the working blueprint will not pull the integer from the target, it simply stays at a default value of 0 and I get the error “Accessed None”. I’ve looked into casting, but I have not been able to even access the nodes (even with context sensitive turned off). Any Ideas?

I had this same issue with a few of my blueprints

Hi there a while back I was beating my head on the wall trying to figure out this error. I didn’t find any proper advice or at least nothing I could understand, however I did figure out what I believe to be the problem and wanted to share my findings. The “Accessed none” error seems to derive because one blue print is looking at another blueprint for a variable of sorts as you mentioned; what I found to be the problem is at run time when blueprints communicate with each other they do it in game so both blueprints need to exist in the game world or else the spawned blueprint is saying “that it cannot find this variable because the place your telling it to look is not found in world.” for example I had my pawn blueprint looking into a weapons blueprint for shot cost but the variable was not found in my pickup mesh but in my spawned weapons mesh and when the pawn blueprint was looking for shot cost var it had not spawned yet hence it originally was passes an “accessed none” value but then I noticed after the weapon had spawned and was fired at least once the variable was found and my ammo would be decremented after. so I joined my pickup mesh and weapon mesh as the same blueprint always in world to fetch any data from each other as needed. With this in my workflow now for handling in game variables I dont get the Accessed none error. Also for other in game run time variables I’m starting to either use an empty blueprint container that I keep in the level from start to finish to handle other needed variable. I also believe that Blueprint Interfaces can be used to avoid this but this is only speculation on my part because I can only get my interfaces to pass variables from my player pawn outward not the other way around.(I need more interface practice :stuck_out_tongue: lol) but as I method first about alwasy having communicating Bps spawned in game works well for my crew and I hope this help you.

P.S For the casting question I usually run an onbeginoverlap check draw a wire from the actors blue node and type cast to (whatever other blueprints name is). or you can just add the blueprint as a variable in another blueprint, when creating a var in the graph instead of picking int, bool, etc type the name of your Bp and it should come up just make sure you tick all variables you want to share as editable and give it a comment for clarity or else I believe the var stays local to its own Bp.

Hey thanks for the tip. I had a programmer friend go over my blueprint and he pointed at that although I was getting the target blueprint as a variable, I was not setting it. As for the casting, he had me do that in the target blueprint rather than in the working one, which is something that had not occurred to me to try. Based on what you posted, using a set node in the right context should fix your issue.

You can also use a isValid node to check if the node you want to access is a valid object, so basically use this whenever you retrieve a object variable before you use or cast it.