Referencing a variable in GameMode

I am currently using a timer that is being calculated in the GameMode EventTick

When my game is complete, I want to stop the timer by setting EndGame to true - essentially giving the player their time.

I want to stop the timer when the player reaches a certain point, hence i want to set End Game to True when the player reaches this point, I have done this on my Actor BP:

I get an error when reaching this point as the player

The End Game variable is set to public/editable.

Any help is appreciated.

You have a couple of problems there.

  1. I assume you’re trying to make a per second timer, but putting delay on tick has no effect. The code you have on tick will ignore the delay, and run every frame. So, you’ll probably be getting crazy results.

  2. You have a variable of the correct type, but you have not assigned it. It actually need to be pointing at the actual game instance. Everywhere you want to do that, you will need something like:


You can do the timer like this:

Thanks a lot, casting to FirstPersonGameMode did the trick.

Interesting about the event tick, i followed a tutorial and it seems to work with my limited testing.

I’ll keep that in mind though,