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.
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.
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.
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.
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.
I recently faced a probably identical issue, and I found out about the cause.
Sometimes, when you add an Actor Component, it might appear in the Component tab, but its actually not added.
To know if you are facing the same issue, do the classic turn off and on unreal editor, re-open the Blueprint, and check if the Actor Component is still present. If it is not, the issue is likely the same.
Just re-add the Actor Component, and it should work fine after.