Download

Some Issues with Casting and UI

Hey guys, so I’m having some issues getting casting and my UI working how I want them. Here are the 4 blueprints associated:




Basically, I want a screen to come up when you start the game, with options to start new or load and settings, as well as being able to press Esc to bring up a Menu, and F5 to create a quicksave file.

The start screen comes up fine at the beginning, but I’m unable to actually click the play button. I don’t know how to make it load the level upon clicking play, but realized the level was loaded behind the UI anyway, so I just tried to make it where it removed the UI upon pressing play.

And, this isn’t really related to blueprints but, I have tree models with 3 LODs, when I use the foilage brush to paint them on the landscape, only the lowest model shows regardless of how far away it is. I’ve tried adjusting the screenspace scale settings, but it’s only adjustable on the base LOD, and changes nothing…

I appreciate you guys help a ton, thank you!

Bump. Still hoping for some help.

Bump again.

Are you getting any ‘cast failed’ outputs? What happened when you tried to make the UI go away upon clicking play? I also noticed nothing is linked to the execute node of VG Game Instance. And you shouldn’t bump something until at least 3 or 4 days go by. I understand your impatience, I am the same way, but the moderators do not like frequent bumping.

Yeah, that’s all I get, are the cast failed returns.

And I’m unable to click the Play button, it doesn’t even recognize when my mouse is over it.

Yeah, that part doesn’t actually have any functionality right now, and isn’t involved with the issues I have.

You need to cast using an object. I’m not sure how you have it set up, but in the cast to main menu connect some sort of ‘Get Main Menu’ to the object input.

Yep as Jamendxman3 said, you need to pass across the object to cast to.

For the LOD stuff you will want to check your settings, have a look under your rendering quality at what settings you have got there.

The Main menu was the only one I had forgotten to connect the object to, and it didn’t change that I can’t click the Play button.

What do you mean by Rendering options? All my engine settings are set to the maximum.

Why don’t you run a print string node after the Play Button code to verify that it truly isn’t working. Just to make sure it isn’t some sort of visual glitch.

Tried that, and I still just get nothing…

Time to start dropping some breakpoints on parts of your code and see whats happening.

What exactly does a Break do?

Hi Acurapassion,

Breakpoints allow you to stop a blueprint at a specific node that you specify, much like breaks in C++ do for code. It is a way to visually debug your script to see what is occurring. However, the problems you are running into are potentially two fold. The first is that your mainmenu cast is casting to a NULL value, so you have nothing to cast to. This will cause it to instantly fail. You have to have a populated variable to cast to your MainMenu. Your EscapeMenu looks to be closer to correct, but depending on whether or not you have populated your EscapeMenu variable will determine if you are getting a NULL value or if it will work as intended. If you right click on the EscapeMenu variable and press Watch this Variable, you should be able to press PIE and see if the variable returns null or has a value. If it is NULL, you need to populate it before you can use it.

Hey

What kind of class is MainMenu? I mean when you created it, what did you choose as it’s parent class, just actor? If it is an actor, how is it being created/spawned in your game? If your main menu isn’t doing anything other than creating/removing your mainmenuwidget when it is told to by those interface events, It may be much easier to just put those events in your playercontroller, or even gameinstance. (which is what I would do, but I use gameinstance for so many things)

If your mainmenu is just an actor, it may not even be created when you play the game, you would have to spawn it from somewhere, and then get a reference to it. You can get a reference to a playercontroller from inside a widget by using “get owning player”, or get a reference to the gameinstance by using “get game instance”.

Yeah it’s an Actor, sorry I’m really not fluent on what the Game Instance even is, much less when to use it and when not to… I do feel like I’m finally getting a grasp on the blueprint system, however, things like this still confuse me…

So, I had a bit of a breakthrough last night with my casting. The only things I could really tell from using the breakpoints was that my variables had null values. So, I started looking around, wondering why this would be, and that possibly I was trying to cast the wrong value, so I tried several different things. And I came across a video talking about how certain things need to be put in a persistent game instance, so that they can be used at any point, like, before a level is loaded. So, I started examining my code, and it occurred to me (like I just realized Zurael already said) that the actor wasn’t actually in the game when I was trying to make the call, so I was essentially trying to cast to nothing. As soon as I converted the escape menu over to the GameInstance, instantly started working, and my Quit game button in that menu even works! Haha

However, I’ve tried a few different things, but I still can’t seem to change the fact that my play button still does nothing, or just doesn’t receive my clicks… I tried RemoveFromParent, as well as RemoveAllUI. And, I also can’t seem to get the hover to work, even on my working EscapeMenu.

So, one of my biggest problems is now solved, so thank you guys again very much!