I have an actor which has an inherited TArray variable from C++. I added some components to the actor and I want to store those components in the TArray variable. When I add those components in the Blueprint, the array acts weird. I just add 1 component but it shows me that the array has 7 elements or something like that. (That number is always random when I close and open the editor.) When I try to access a variable of the array, it gives me an error. Even the 0th (first) element gives me an error.
I tried to add those component by using both BeginPlay and Construction functions, but it didn’t work.
NOTE: When I came across this issue before, I had to open a new project, copy all the C++ classes to the new project and create all the Blueprints again. Now, the project is big; so that I cannot create a new project to solve this issue.
I am not sure why this happens, but I have also another code which is similar in the same project, and it doesn’t give me any error and it works perfectly (even in the packaged project).
The problem is not about the size of the array. It is okay if the array has 7 or 11 or more elements. I check if the element is null or not. The interesting part is: even though I check null pointers, the code says the element is not null. I do something in the code by using the element and it gives me an error as if the element is null.