accessed none trying to read property combat system ue5

I´ve been following this series but got an issue in my game. I tried to ask in the comments but nobody is answering me. So, my sword doesnt spawn and when I press back Q,(input) the sheathing animation freezes. When I stop playing the level, gives me an error both in “Spawning Gear” and “Destroy Gear”.
The message is: “Accessed None trying to read property”

Video: https://www.youtube.com/watch?v=5Uqy7rqLp4Y&list=PLVcVWC1bK3YV1y98Wa_DSv3ZzhDiQh480&ab_channel=CrystalClearGameStudios

Hope someone see this.

Hello @BabyZezinho can you send pictures of your blueprints and a picture of the errors you are getting ? So we can see where the issue is comming from.

Hey there @BabyZezinho! As AOB mentioned, it’d be easier to tell what’s going on if we saw the blueprint for sure. Though accessed none as an error stems from a blueprint trying to use a variable that is null, so it’s possible that your weapon variable that you’re trying to access hasn’t been set or is being unset or destroyed before you try to access it.

1 Like

Sure

i can only send one Screenshot because I´m a new member.

This is the DestroyGear, that is when the character sheaths the weapon. It happens both in SpawnGear and DestroyGear. (I´m new to UE5).

@BabyZezinho Are you sure that the player reference that you are getting is valid?

@BabyZezinho you can also use AnimNotify blueprint instead here’s how:

  1. Right click in your content browser select blueprint class and search for AnimNotify create a new AnimNotify
  2. Open it and override the function called Received Notify
  3. When you click Received Notify just get the owner cast to your character and call the function
  4. Go to your Anim Montage and add the notify
  5. Example use (in your character blueprint)

When we press 1 the AnimMontage is going to play with the destroy gear custom event

Ok, I did that, but didnt do anything in game, because I´m trying to do something else. I´m using an Animation Blueprint.

By the way, I added “Is valid” to that player ref, both to SpawnGear and DestroyGear. Is not happening the error anymore, but the Sword still doesnt show up in game. Those notes are in the Event Graph of the Animation Blueprint

Reply so I can show you the note update

Not sure what I did here, but at least the Log Error is not happening anymore. As I said, I´m new to UE5.

Can show what you have in spawn gear ? And the is valid on the destroy gear notify event will return not valid because you haven’t plugged anything for the input object. You can also put print strings out of the invalid outputs for debugging.

The LogError hapens because of that animNotify as it was before.

SpawnGear:

This is the Spawn Gear Notify

@BabyZezinho I meant to show your code in Spawn Gear the problem is probably coming from there.

Oh,right. I can´t zoom more than this

Don´t mind the comments. Theyre not in english.

@BabyZezinho The code here seams to be fine. So there is 3 reason why it might not work.

  1. Check if the class you are getting from the struct is assigned to be the sword class.
  2. Check if you are matching the slot name correctly.
    3. And ensure that the SpawnGear function gets called. The Player Ref might not be valid and the function is never called. Actually you were getting Accessed none earlier so this might be the problem. To test it just put print string node in the Spawn gear and see if something gets printed when you take out your sword if it doesn’t that means Player Ref is invalid.

Edit: If the player ref turns out to be invalid send a photo of where you are setting it so we can fix it.

1 Like

Alright. I think I got it. As you said, I went to check on my PlayerRef and wasnt there, in place.

Now, the sword and shield already spawn, thanks for your help!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.