Changing HUD at runtime based on actor type?

So this is a similar to a question I asked recently, but different enough that I deemed it okay to be a separate question.

Link to my other question

I was wondering, if I have a playercontroller jump from possessing actorA (ground unit) that has a certain HUD to actorB (air unit) that has a different HUD, how do I go about destroying actorA’s HUD and instantiating actorB’s HUD? How do I know what type of HUD to instantiate? Should each actor have a static CreateHUD function? Do I just not understand how HUDs work!?

Thanks a lot all, I hope someone can help :slight_smile:

-Austin

I’d have a base class called UnitBase. UnitBase has a property that holds the class of the hud to spawn when possessed. Then you call OldHud->DestroyActor() and SpawnActor() for your new hud.

So when possession happens, the controller will destroy the old hud and spawn the new by grabbing the hud class from the actor it’s possessing?

Not automatically. You’ll need to hook that part up. I was talking about how I’d do it :slight_smile:

haha, yeah… I know. I was just making sure my logic was correct. But somewhere inside the Possess(inActor) function I could do this… ???

You could override the posses function, call the base version, and then do your code.