Download

Let's get this real about filling up references

Hi there

I know I’m not the only one with this problem, but it really frustrates me that I cannot truly get how you fill a reference properly. I somehow manage to get it working between an actor and another actor, a widget and an actor, but now I can’t get it to actually work between an actor and my character/pawn. I watched the 2 hours blueprint communication live training 3 times, with 2 of these times being a month ago. I’m not actively going on UE4 as I’m mostly doing it as an hobby for the time being, so I can go 2 to 3 weeks without launching the engine. What I realized is that I never fully understood how to fill a reference as the live training goes bare bone on the subject (It has always been easier for me to understand stuff by reading rather than by hearing, in most cases). As I’m learning I try to check ou threads on the forums and answerhub to see if I can help, and one subject that seems to always be problematic to people is how to get the communication right. A lot of threads have people getting the error code “Accessed none while trying to read XXXXX (The name of your BP reference variable)”, are trying with casting because they had the previous problem, or go on to use “GetAllActorsOfClass”. I feel as a community we should try to better explain how to properly do it, as I’m sure it’ll help a lot of people who are half-understanding it (including me).

So let’s say I start a new project. I create a blueprint with a bool (any other variable would do the trick but whatever). Let’s add a box collision and set and uncheck “hidden in game”. BeginOverlap sets the bool to true, while EndOverlap sets it to false. In the character blueprint we create a new variable as a reference to my blueprint previously mentioned. We get our bool from the BP ref and print it to the screen with the E key. Now we go test it out. When we press E, it prints false (as the default value is false). Now we can enter the collision box and press E. Still says false. When we exit, the message log has a few errors. “Accessed none trying to read property BP”. Now that’s where I know a lot of people have a problem. The variable is empty so it’ll always return false. To “fill” it you need to make you variable editable and select your blueprint in the scene and “fill” your variable with one object from the scene. 2017-08-22 (1).jpg

But the thing that gets me every time is when you include the possibility of having multiple instances of that blueprint into your level at some point later on. When this happens I’m at a loss for words. When this happens, I don’t want to have only one instance of my blueprint communicate with my character, I want them all to do it.

Let’s try to all come together and properly explain how to get your reference properly set up, as it’s a centered problem amongst a lot of beginners to UE4.

Thanks.

Edit: Also, I wrote this at 4am, sorry if it’s ****** around the edges or if I accidently posted it in the wrong forum.