GetOwner() for Collided BSP Primitive is null

I am guessing this is potentially intended behaviour but on collision with BSP brushes, a primitive component exists but using GetOwner() on the primitive component returns null.

I understand that likely means BSP brushes do not derive from AActor (is there a reason they were implemented this way while still making use of normal components?) but are there any other use-cases where a PrimitiveComponent would never have an owner?

Currently, when querying components, I have been using GetOwner() without first caching a local reference to null-check as I was under the impression a component could only exist as a subobject of an owning Actor (as objects cannot exist in the scene without deriving from AActor, as far as I am aware).

I encountered this through raycasting - I was caching the hit component for use later, where I need access to the owning actor; this caused my Editor to crash, leading me to discover GetOwner() returns null on hit components when raycasts collide with BSP brushes in the scene.

Hey -

While I understand your thoughts on actors in a level, it is still a good idea to always check if the return value of a call (GetOwner() / GetWorld() / etc.) is valid before using it. That being said, I was able to reproduce the behavior you described, however BSP are not typically meant to be used as final assets in a level. They are mostly used to first prototype or block out a level before being replaced with or converted into a static mesh. Indeed, if you convert your BSP to a static mesh (Advanced dropdown under Brush Settings) you will get a valid owner returned.

Cheers

1 Like

Thanks. Yeah I typically null-check any pointers before using them and I’m definitely not using BSPs as final assets. It just means, when prototyping with BSPs, if a null check isn’t in place it causes a complete crash.