"Accessed None trying to read property ActorComponent" after closing and reopening the project.

Hi, so recently I’ve been having an issue where whenever I close and reopen my project, the actorcomponent that is on my character scripts comes back empty. I’m not sure why this is happening, and when I delete the component and re-add it to the base class there are no errors and it works fine, however after saving, closing and re-opening, the runtime error “Accessed None trying to read property (ActorComponent)” returns. If anyone has any idea why this is happening, I’d greatly appreciate any advice.

For some added context, the actors that I’m trying to get the ActorComponents from are all what you could call “grandchildren”, as in they are two stages separated from the highest parent. Additionally, I recently moved the entire content folder to a new project as I had some issues with the previous project. That old project has now been deleted completely. I have no idea if this is causing the issue, but I figured it was worth mentioning. Finally, the array of actors I use gets set in the GameMode’s BeginPlay event, and the actor array DOES store the actors correctly, after they have been spawned, and I see no reason why they would either spawn without the components or that the components would not be set up before getting all actor details.

I’m at a loss as to why this would be happening, so if anyone could help that’d be great.

Can you show the blueprint?

This is the UnitBase class, which all the characters are based on

This blueprint. :point_up_2: or where the Access none error is happening.

Oh, my bad. This is where the error is happening, inside a function in the GameMode blueprint. The “Actor Array” is an array created by doing a get all actors of type UnitBase and this function is called after that array has been created.

Is it called once after created or multiple times throughout the game?

If I’m not mistaken all actor and components should be initialize at BeginPlay so once right after created shouldn’t be an issue.

It’s only ever called once, and that’s what I thought, I don’t know why it’s giving an error since all actors and components should be initialized by the time it tries to get the CombatComponent, and even adding a delay doesn’t seem to effect it so it can’t be that the components simply aren’t set up by then. Not only that, it also works perfectly fine when I re-add the CombatComponent so I don’t know why it’s throwing an error.

Is the component created or added in c++?

Nope, all Blueprint.

Well my 2 bets were an actor destroyed during play or garbage collection doing its thing…

Think you can share a project only including the game mode, actor and the component with the issue?

Sadly I can’t because I’m still a new user on the forums. The actors aren’t being destroyed, they remain in the scene the whole time. I did make a project that only included the actors, game mode and component, but I still get the issue.

Can you post links? Wetransfer is free; email it to yourself and paste link here.

Here, try this.

1 Like

I’m not getting any errors. :eyes:

image

Copied that exactly and still got an error, prints null.

Wish I could be of more help, but I don’t know how to replicate the problem to try and find a solution, sorry.

1 Like

No worries, thanks for trying to help atleast. At this point I might just have to restart sadly, I don’t know what’s actually causing it and it seems like an error on my side. I’ll try reinstalling UE5 and see if that helps.

1 Like