Download

"Set Timer by Function Name" doesn't work for me. Following book example. Can't see the difference!

I’m reading “Unreal Engine 4 Game Development in 24 Hours” (where each hour dilates to about 3 hours when I try to do it :smiley: )

On Hour 21, we are meant to use, for the first time, “Set Timer by Function Name”, with the “RestartGame” function on the GameMode. It doesn’t work for me. I tried other methods, like “QuitGame”; nothing works. But I see that the “Set Actor Hidden in Game” works, so I know the OnDeath function gets called. I downloaded the book example, which works; I can’t see the difference! See picture…

[ATTACH=CONFIG]OnDeath[/ATTACH]

Which version of the engine are you using and which version of the engines does the tutorial refer to?

In 4.15 *GetGameMode *returns GameModeBaseReference while the *RestartGame * function requires GameModeReference - have a look at the output log, you should see a warning regarding bad function name.
You may need to cast it first:

gameMode.png

Yikes not a fan of this book’s approach. Whatever this BP is about why not create a local Custom Event…?
Call that ‘EndGame’ etc, and link it to the Timer instead, and have it invoke Gamemode → RestartGame func.
That way you can put a breakpoint on it, look at the log, and you know where its failing more precisely etc.

If I cast, as Everynone suggest, nothing happens, so I used Print String on cast failed, and output the object class. The cast does fail, with object class “ArcadeShooter_GameMode_C”, which is my game mode. So it seems my game mode cannot be cast to game mode; strange.

And if I don’t cast, the log says (I forgot to look there first before posting; it’s the first time since I started that book where I got stuck, and that “visual programming” is making me forget how to debug) “Warning: SetTimer passed a bad function (RestartGame) or object (ArcadeShooter_GameMode_C_0)”, so it looks to me like both the function name and the object are correct.

… later …]

When I look at the ArcadeShooter_GameMode Blueprint, it says: “Parent Class: GameModeBase” ; that seems to be the problem. Changing the base class fixed the issue.

Casting is like a gameplay-trap / pitfall the on-screen player-character keeps falling into etc. :stuck_out_tongue:
If you’re not benefiting from inheritance it over-complicates things thanks to C++ vs. Kismet.
In the pic you cast from Gamemode to Gamemode which is redundant / may fail w/ an error…
Cast needed was Gamemode to ArcadeShooter_GameMode (books often go out-of-date too)!

I can confirm changing the GameModeBase parent class to GameMode still works. I spent way more time on this then I should have. It appears most tutorials need the original GameMode.

From my understanding GameMode is now a subclass of GameModeBase that handles loading/reloading the levels?