Cast To ... (Other UMG BluePrint)

Hi guys, “Cast To …” I have a problem with the function, if I call a simple function (without the class) it gives me an error when compiling, if I use the function to obtain the Class ( Cast To … class ) that when testing UMG just flies all the time gives a warning …

P.S I do not understand English very well …

You need to provide the object to Cast to SelectLevelMenu. You will need to get a reference to the blueprint you want to cast first, because you’re spawning it in that script itself you can simply store the result of Create Select Level Menu Widget as a variable, and provide that to Cast to SelectLevelMenu

However, in this case because it is already a SelectLevelMenu there is no need to cast it.

Think of “Cast” as a way to interpret an object as something else. It’s not a way to retrieve an object.

I tried as you said, it turns out here such:

All the same, a warning appears and crashes at startup for testing …

How does SelectLevelMenu know which level the player selected? Can you show us that code? I don’t see why you would need to cast here at all.

You don’t need to cast an object into itself, that’s why you’re getting the warning, just remove the cast node altogether - you already have a SelectLevelMenu as a result of having just spawned it in the same blueprint and execution chain. If you’re getting a crash you should post the crash log in a separate question (it’s unrelated).

Ah also, make sure you reply to an answer rather than replying with an answer. It will make it easier for people to help you :slight_smile:

Thank you =) I did as I understand what you said and I now always selects a default value that I put in SelectLevelMenu, turned out is such a chain of actions:

Glad you got it sorted! Don’t forget to mark the correct answer to help others who come here from Google.