Call BeginPlay() form inside UObject

I’ve derived from GameViewportClient. I need to cast to a subsystem I’ve made when the game begins but I’ve noticed UObjects have no BeginPlay() function. Is there an equivalent I can use?

I was thinking of overriding the Init() but I am am not sure when it runs. Will my subsystem even exist at this point?

Can’t seem to use the constructor in this class either as it says:

/** DO NOT USE. This constructor is for internal usage only for hot-reload purposes. */ UGameViewportClient(FVTableHelper& Helper);


It seems more likely that your subsystem will be able to get World->GetGameViewport and setup whatever when necessary, rather than getting the subsystem inside the game viewport… thinking further, is that even the correct interaction for what you need? what if there is no game viewport?

I actually need to go the other way. I don’t think I can reliably do GetWorld()->GetGameViewport() because the subsystem is initialized before my viewport even exists as far as I can tell.
I am trying to cache a pointer to my subsystem inside my game viewport. This is so I can intercept and store specific touch input data in my subsystem for use elsewhere.

I am assigning values to my subsystem on tick from an input function so I was trying to find a place inside the game viewport to do something like MySubsystem = GetWorld()->GetSubsystem<MySubsystem>() as I don’t want to keep assigning the subsystem every tick.

I’m thinking that overriding the Init() function in the game viewport may be a good idea?

Thanks for the reply.

yeah i guess that does make sense. So, yeah, Init() looks to be for that sort of a purpose, just make sure you call the super :slight_smile:

It seems to be working as expected so far. Thanks for the help!