Hi, I have been working on creating a simple game (a coin pickup game).
I just made the main menu for the game. However, the menu does not show up when I combine all of the items and files required for the game together. How can I fix it?
I put some screenshots to describe what I have for now.
You reference them as files, but those are just folders you are talking about. They are irrelevant to the functionality of the game, and only serve to organize your workspace. The “files” are the blueprint classes and other such data you create, like the main menu widget. These can be put anywhere in the folder hierarchy, aka anywhere in the content folder or even the all folder. Again, you can put folders and files anywhere you want so you can find them easier.
Before answering your initial question: First, look at your project settings, and the tab on the left: Maps and Modes.
Unreal will load these by default at engine start. There will always be a Level (map) loaded. Levels can also force a gamemode to be used instead of the default one in the project settings. You can find this option on the currently open level in the editor on the right side (level settings). Similarly, gamemodes can force things like which player controller, pawn class, and HUD class to use per gamemode, overwriting the defaults in the project settings. Note that in the project settings, whatever gamemode is used as default (at the top of the list in my image) will auto fill the classes below it to use. So, you would create a gamemode, and set the default classes to use. Then you can force this gamemode to be used either solely in the project settings, or on a per level (map) basis.
Now with all that in mind, you need to determine what class, such as in the gamemode, player controller, pawn class etc. you want the functionality in for what you are trying to accomplish. Given that you are a beginner, I would recommend putting the code to create and show the main menu UI in the player controller class so it ensures your controller is valid. Now, all you need to do is find a starting point in the player controller class, such as Begin Play. You can then do something like this:
Also, in your main menu widget where you are setting the input mode to UI only, you will need to get a “self” reference and plug it into the input where it says widget to focus.
Thank you for replying but I did not get what I should do. Could you explain step by step, please??
I opened project settings and Maps & Mode.
What should I do from here??
This should be a good point to get you started. Note that you can also construct your widget in your character blueprint, your playerController blueprint, gameInstance blueprint, gameMode blueprint and so on. Constructing it on the level blueprint will ensure that it only gets created and added to screen on that specific level.
Thank you for replying with some videos.
I am sure I am using UE5 and you are using UE4, and there are several differences between them.
On my screen, I could not find blueprint tab. Where can I find it?
Thank you for helping. The main menu shows up, but the start button does not work. Could you help me with that, please?
I replied to another reply that you liked
Edit: apologies, misinterpreted the question. When you say it doesn’t work, do you mean you cant even click the button?
Edit 2: Ah I think I know your “problem”. It is actually working fine. You are reloading the same level you already have open, so it looks like nothing is happening. It is in fact opening the level. The problem is you need to clear the widget from the screen after pressing play. Add the following function: “Remove all widgets”. This clears ALL widgets from the viewport. If you want to only remove 1 widget, you need to save a reference to it in a variable, then use “Remove from parent” instead.
The thing is you are creating your widget in the level blueprint, so if you load the same level, it will recreate the same widget everytime on level load. This is why you should use a blank level when starting the game up, then use your UI to load the gameplay level.