help with cast to

Hey,

what is “HudTimer” for a class? What is the BaseClass of this? Then i can tell you what the Object needs to be.

You need a “created” UObject for this “Object” pin. That could be a spawned Actor. Like your Character, a HUD, a GameState etc.
Or also an Actor you created yourself, like a Button or so.

But this highly depends on what “HudTimer” is. Because, for example, casting a Controller to a HUD brings nothing. It will just fail.

With Casting you make sure that the Object you cast is of the type you are casting to. The cast will only work if the Object is of
that type or if it is a child in some chain of that class/type. And it is used if you want to access variables that are only available
in that class or its childs.

An example:

BaseClass: PlayerController

Child of PlayerController: FirstPlayerController | Has a Variable called “FirstVariable”
Child of FirstPlayerController: SecondPlayerController | Has a Variable called “SecondVariable” and the “FirstVariable” of its Parent.

If you, at some point, get a pointer to a “PlayerController” and you want to make sure it is of Type “FirstPlayerController”, you gonna cast it.
If the cast works (needs to be of type First- or SecondPlayerController, otherwise it fails!), you can access the “FirstVariable”.

If it is “SecondPlayerController” and you want to access the FirstVariable, casting it to the FirstPlayerController is enough. If you want to access
the SecondVariable, you need to cast to “SecondPlayerController”, which will only work if the Actor is really of type “SecondPlayerController”.

Both of these classes can be casted to “PlayerController” but you can’t access the variables with this cast. You can only make sure that they are
PlayerControllers in one or another way.

If you don’t understand this, i highly recommend you to learn “c++ inheritance”. Not the code form, but the logic behind it. Blueprints
are C++ and you need to understand the basics (: