Change Object properties after Spawning

The program stores the Mesh in a TArray after spawning, but when I try to modify anything from the object it gives a runtime error.
In the example above, I try to Destroy, but it execute the error with any change, although, It does not give the error when getting variables

Any idea of what have happened? Thank you

  • What error do you get? Null pointer exception? And at which line?
  • Have you checked that the objects are successfully spawned? You spawn several cars at the same location…
  • I’m not sure if Cars[i] will work. Does TArray increase it’s size if you access it at an index that is currently not existent? Better use Add() on your Cars array. This function will append an item to the end of the array.

I do not know if it helps, the elements of the array are blueprints.
Can c++ change blueprints outside the variable?
The error is not shown and it appears before spawning when I click ‘play’
I have checked that the the array creates the number I want.

Error or crash (exception)?
When you have a crash, then you get a window that tells you, that you got an exception. To see the call stack, you need to install the debug symbols.

It doesn’t matter that the elements are blueprints.

I have just tried to use a c++ class (non blueprint) and works properly, do you know why?

The blueprint inherits from ACar (directly or indirectly), therefore this is not the problem.
Again:

  1. Do you get an error or an exception with a crash?
  2. At which line do you get the error / crash?

Also:
Print out the length of the array (Cars.Num() ) at the end of each loop cycle and the current index at the beginning of the loop cycle. Calling RemoveAt() does reduce the number of element in the array and therefore you might get the problem at the last index, because that index does no longer exists.

Thank you so much for your help.
I had a problem with TArray, but until I had not re-built the project, the error did not disappear.