Problem with referencing a Child in another Blueprint

Hi

I’m a total newbie with Blueprints. I decided to follow a course on Udemy to make a retro FPS. The course makes use of Unreal 5.1, whereas I’m using 5.3.2. In the video, the player controller nodes are within the First Person Blueprint. On mine, the controller is separate Blueprint, along with these nodes:

In the video, these nodes are connected at the end:

As those nodes are in their own Blueprint, I’m guessing the ChildActor I need to add at the end would need to be referenced from the other Blueprint…? Although I’m not having much luck achieving it.

This final portion, in my First Person Blueprint, is failing to work:

So whenever I try to fire during play, I get this error:

Blueprint Runtime Error: “Accessed None trying to read property Main_Weapon”. Node: Shoot Weapon Graph: EventGraph Function: Execute Ubergraph BP First Person Character Blueprint: BP_FirstPersonCharacter

If I can’t reference it, what would be a way around this? Again, bear with me, as I’m totally new to Blueprints. :sweat_smile: I will probably have to look at following a beginners course first.

Blueprint Runtime Error: “Accessed None trying to read property Main_Weapon

How does the Main Weapon actor instance get into the game?

  • do you spawn it?
  • is it sitting in the scene and you pick it up?
  • does the player already have it?

The player already has it. It’s a child of the first person camera. A 2D sprite.

So what exactly is stopping you from doing what was in the tut?

Is the input in another BP? Or in the one owning the child actor component? It’s a bit unclear what is what.

Okay, in the tutorial, the guy puts these nodes…

…at the end of these Input Mapping nodes…

In his version, the above nodes are within a single Blueprint called BP_FirstPersonCharacter. Other nodes like Camera Input, Movement Input, and Jump Input are within that same Blueprint, too. All within that Blueprint, his FirstPersonCamera is in the list of Components, and he creates a ChildActor and makes it the Child of the FPS Camera. I’ve done the same, too.

However, in my version, when I created the FPS template, the Input Mapping nodes are in their own Blueprint called BP_Player_Controller. And so I’m unable to add the nodes from that first image at the end as there’s no ChildActor/FPS Camera components. Hope that makes sense. :sweat_smile:

Thanks

While you could get the controlled pawn in the controller and cast it to the character, doing so just so these nodes can be added immediately after the add mapping context is in no way neccassary.

The code does belong in the character, so just create the missing Begin Play event in the character blueprint, and connect up the cast and set there.

If you really want things to look the same as in the tutorial, you can just move the input mapping stuff back into the character bp. It will work either way.

1 Like

Do the child actor thing in the actor that owns the component. In the first person BP.

I think I already tried that? I did copy and paste the Input Mapping nodes into the FPS Character Blueprint, however, I still get the runtime error:

Blueprint Runtime Error: “Accessed None trying to read property Main_Weapon”. Node: Shoot Weapon Graph: EventGraph Function: Execute Ubergraph BP First Person Character Blueprint: BP_FirstPersonCharacter

I figured that error was related to the nodes being in the wrong Blueprint compared to the tutorial, but apparently not…?

No one is asking about that. Could you show the component hierarchy of the first person actor, the one the above screenshot is from. You said:

The player already has it. It’s a child of the first person camera. A 2D sprite.

Could we see that?

No, but that’s actually the main issue I’m having. :sweat_smile: Sorry, I should’ve mentioned that in the original post. I assumed (dangerous, I know) that the issue we’re talking about is the reason for that runtime error.

But here’s the full FPS Character Blueprint:

It’s right here:

image

So:

Cast to whatever type the Main Weapon is, same as in here:


the issue we’re talking about is the reason for that runtime error.

The issue stems from the Main Weapon variable having no value - this reference is not pointing at any specific object. The above script asks the Child Actor Component for its actor, and assigns it to the Main Weapon variable, so it’s easier to use later on by fetching a single node rather than casting every time.

In short: the editor does not know what Main Weapon refers to; it’s your job to populate variables with pertinent values. Imagine if you created a String variable but forgot to type the text. You do have a variable but it is empty.

1 Like

Okay, that appears to have helped; it’s removed the runtime error anyway. So thank you for that. :grinning:

However. :sweat_smile: The purpose of this step in the tutorial is to get a line trace to work and fire from the gun. One shows up when pressing fire, but it only shows the once. I think it kept showing for the guy in the tutorial when he fired.

The main problem now is that the flipbook animation isn’t working still. By this point in the tutorial the sprite for the pistol is supposed to play its animation and fire when clicking the left mouse button. I presume this is why those nodes were added at the end of the Input Mapping modes…?

No.

On mine, the Child Actor Class has a BP_Pistol Blueprint assigned.

I’m not following your tutorial so I just put a random thing there. :melting_face: To demo.

It might be easier if I just download the same version as in the tutorial - 5.1 :sweat_smile:

Nothing has changed between those version, not in regards to what you’re doing. My suggestion is to re-trace (emh) previous tutorial steps.

Okay. Was just letting you know for clarification.

if you need extra help, clarify what this is (supposed to be) doing:

You mentioned:

  • tracing
  • playing flipbook animation

How is that done?

Okay, after spending a load of time typing out and sharing pics of each step, that allowed me to check through everything, and I discovered a couple of nodes weren’t connected. :sweat_smile: Specifically the Event of shooting the weapon and linking it to Set Flipbook, which plays the Pistol Firing animation.

I went back and modified things to match the tutorial again, specifically with the Input Mapping nodes, and copying/pasting them into BP_FirstPersonCharacter, along with those Cast nodes, but that gave me the runtime error again. So copying them over to the FPS Character Blueprint doesn’t work. So @Everynone’s suggestion of adding the Event Begin Play has sorted the issue out. Thanks again! :smile: