# Changing HUD at runtime based on actor type?

**URL:** <https://forums.unrealengine.com/t/changing-hud-at-runtime-based-on-actor-type/299569>\
**Category:** UI\
**Tags:** playercontroller, possess, hud, unreal-engine, CPP, question\
**Created:** [November 21, 2014, 8:21pm UTC](https://forums.unrealengine.com/t/changing-hud-at-runtime-based-on-actor-type/299569 "2014-11-21T20:21:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AustinK](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/austink/32/1088212_2.png) [@AustinK](https://forums.unrealengine.com/u/AustinK)\
**Post date:** [November 21, 2014, 8:21pm UTC](https://forums.unrealengine.com/t/changing-hud-at-runtime-based-on-actor-type/299569/1 "2014-11-21T20:21:41Z")

</div>

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](https://answers.unrealengine.com/questions/135550/possess-different-types-of-actors.html)

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 🙂

-Austin

---

<div class="post-metadata">

**Author:** ![joeGraf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@joeGraf](https://forums.unrealengine.com/u/joeGraf)\
**Post date:** [November 21, 2014, 8:42pm UTC](https://forums.unrealengine.com/t/changing-hud-at-runtime-based-on-actor-type/299569/2 "2014-11-21T20:42:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AustinK](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/austink/32/1088212_2.png) [@AustinK](https://forums.unrealengine.com/u/AustinK)\
**Post date:** [November 21, 2014, 10:21pm UTC](https://forums.unrealengine.com/t/changing-hud-at-runtime-based-on-actor-type/299569/3 "2014-11-21T22:21:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![joeGraf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@joeGraf](https://forums.unrealengine.com/u/joeGraf)\
**Post date:** [November 21, 2014, 10:23pm UTC](https://forums.unrealengine.com/t/changing-hud-at-runtime-based-on-actor-type/299569/4 "2014-11-21T22:23:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AustinK](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/austink/32/1088212_2.png) [@AustinK](https://forums.unrealengine.com/u/AustinK)\
**Post date:** [November 21, 2014, 10:25pm UTC](https://forums.unrealengine.com/t/changing-hud-at-runtime-based-on-actor-type/299569/5 "2014-11-21T22:25:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joeGraf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@joeGraf](https://forums.unrealengine.com/u/joeGraf)\
**Post date:** [November 21, 2014, 10:32pm UTC](https://forums.unrealengine.com/t/changing-hud-at-runtime-based-on-actor-type/299569/6 "2014-11-21T22:32:36Z")

</div>

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