After Adding Blueprint Editor crashes [Found Solution, Don't know why it worked]

After creating the blue print doors the app crashed when i tried to run it. I checked the logs and I didnt find any clues. Eventually after checking all my pointers i made this change:

for (const auto& Actor : OverlappingActors)
{
	if (!Actor) continue; // ADDED THIS
	TotalMass += Actor->FindComponentByClass<UPrimitiveComponent>()->GetMass();
}

Adding the continue. This corrected the issue but i wanted to know why? Why would there me a null or invalid pointer added to the collection? Keep in mind it crashed on load, nothing is on the PressurePlate yet

Now i’m confused, I removed that line that i thought fixed it and its still working. I didn’t change anything else.

I’ve edited your post to use a code block, please do so in the future.

TotalMass += Actor->FindComponentByClass<UPrimitiveComponent>()->GetMass();

This line has the potential to crash. What if FindComponentByClass failed to find a UPrimitiveComponent? It would return nullptr and then you would be dereferencing it.

1 Like

Thanks always for the help, I have added more defensive logic and things are running properly

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

Privacy & Terms