Following an example to count all items in a level that has specific class I create the blueprint as you see in the picture to run in construction scrip of a blue print game mode but the problem I get total item of 0 and when I debug I found that the construction script never run !! any idea why is that ?
Breakpoints don’t do anything with constructors. They are being run (if they are in the world) but you can’t debug them. You need to throw in PrintStrings to see what’s going on.
Debugging constructors is really painful.
If you can debug and step through constructor code I’d certainly like to know how.
Did you put the print string in the constructor? If a print string in the constructor shows at all then that means the constructor is being run at least.
I can not set breakpoint on constructor ?. I also print string the variable value total blue picks and total pink pickups they are always 0 while there are many static meshes in the level that has both classes.
I tried now again and I create a print string node after I set the value to the total blue pickup and I set to get the number from the variable and nothing is getting printed. The constructor is not running. How I can make it run ?
I am learning and I am just following an example. It is a game mode blue print do I need to put it in the level ?
It will run when you plop an actor in the world or move an actor already in the world.
Maybe tell me what you’re trying to do. You may not want to use the constructor at all.
You need to go to “World Settings” and tell the level what GameMode to use.
If you want to do this at runtime then go to the main EventGraph, create a BeginPlay node and move everything from the constructor over to that.
Blueprint constructors are mostly for setting up actors in the world from the editor. I’ve never had to put anything in my GameMode BP constructor.
I don’t know what the tutorial is trying to do. When I run GetAllActorsOfClass in my GameMode constructor, I get no results. If I put it in my BeginPlay, it works. I can’t speak to much else except to say maybe that’s not the best tutorial. A lot of people put these up as they’re learning themselves so they’re rarely showing you the best way to do something.
Found a forum post says that the GameMode constructor is called before the level is loaded so there are no actors there to find (GetAllActorsOfClass function not working on Construction Script Third person Game Mode - Blueprint - Epic Developer Community Forums)
it was not set in the world settings so I set the “GameMode Override” to “MyGame” but strange thing happen the print string print hello while I am in the view port (design time) but when I run nothing get printed !!
But the instructor set the variable values in constructor script tab and it work in the video tutorial and he was able to read the variable value in the EventGraph as you said using the BeginPlay node so what is wrong ?
as you said moving the script to “Event Graph” is working fine but in construction script I can not set variable value that hold the count of all meshes of specific class ?
Thanks alot yes that explain the result we get. my tutorial seems old. Please stick around
The easy answer is to just stay away from the game mode constructor until you learn more. I’ve been at this for a few years and I’ve never touched the game mode constructor so it’s probably safe to ignore.
Look at the last post in the forum thread I linked. Sound familiar? Maybe you are looking at a tutorial that won’t work anymore.