Need help with "Accessed None trying to read property [character reference]"

The issue comes when I use this variable to reference the player character and its variables. It worked fine the last time, but now it suddenly doesn’t. This happens everywhere the variable is used.

Could you please screenshot the place where your TPCharacterReference variable is initialized? It’s either not initialized before this logic is ran, or it’s initialized before the character is available, or it gets cleared for some reason; whichever the reason, we’d need to see a screenshot of the initialization logic to help. :smiley:

What @Kemichar said, PLUS you don’t do any movement based code in the weapon class. You create an event in the character class that handles it.

Input action → Do stuff in character class that affects character → then call event on weapon to do weapon stuff

Thanks, I’m still learning the basics and have not initialized the variable at least intentionally. Where could I check whether I have or not? If I have not, how do I initialize it?

Noted, will do!

Hey @Ruupi123!

Simply setting your variable’s type to “BP Third Person Character” isn’t enough.

To reference the character, you’ll need to use the set type node of your variable, and connect it’s input pin to the output pin of the correct Cast To node like this:

In this context, you’ll always wanna connect the Object pin to either Get Player Character or Get Player Pawn. But if we weren’t casting to the player character, what to plug into the Object pin would depend on how we expect the player to interact with the actor. Here are some examples:

Hope this helps! :innocent:

2 Likes

On Listen Server this will always reference the Host. The index based nodes are for SP/COOP.

The following nodes aren’t used for Multiplayer.

1 Like

Shoot, not really experienced in online multiplayer yet. Thanks for that!

1 Like

Op should be using interfaces. There’s no reason to have a reference to the character in an attached actor.

e.g. The character class would have a simple BP Interface (BPI_Pawn) for passing specific called for data back to various classes (weapon, controller, player state etc). In the weapon class you use Get Owner as the reference to the base owning class (Character/Pawn) Then call a BPI_Pawn function.

BPI_Pawn :: Get Character movement component

In the character class you’d edit the interface function to pass CMC.

Weapon class

No need for a cast or reference