How to cast a variable from HUD to a ThirdPlayerCharacter?
Just get hud from player controller and cast to your special hud.
You cannot cast a player to a different thing !
Also, it's always good to upvote people who have helped you, you'll have more chances to get help in the future ;)
and make sure your special hud is selected inside the game mode
EDIT: Okay, since people need to insult the intelligence of those trying to help - when the questions are not that clear themselves... First you need to spawn the "Widget" (if not already done) and connect it to the viewport. When you create the "Widget" - it is best to store a reference to it in a variable, that way you can easily communicate with it in the future.
ALSO: when you cast to an object, you need to PASS it an object - the controller CANNOT be casted to a HUD, because it is not a HUD - its a controller.
A simple example of using a "Cast To" node. Raycast -> hits an object, Cast the object to (example) "Third Person Character". IF the cast is successful, then you clicked a "Third Person Character" and can "safely" use functions (or store a reference to it) found in that object, otherwise it is someother object, that we may not care about (and may not have the functions we want to call on a click.)
I recommend doing this. Just save your HUD as a variable when you add it to your viewport. When you need to use a variable from the HUD, just get HUD variable, and get the variable you need from it.
answered May 28 '18 at 03:53 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here