Can anyone help me with this? I’m trying to make a timer, but want it to run over other levels, there is probably a much more efficient way of doing it than just a delay but I cba to search around basic tutorials that I have done before and was little/no help. So timing is off a bit anyway due to lag I think, but I attached the two variables to a text box binding(format text etc.) and it just shows up as 0 : 0 forever, I removed the gameinstance bit and just used the game mode blueprints variable s and that worked (thought won’t carry over as character resets I think?). Anyway any help at all will be appreciated or links to good tutorials.
Following up on this, you can also right-click the cast-to node and convert it to a pure cast node. This would mean that the order no longer matters, and all the rest of your blueprint could remain the same.
Generally pure-cast nodes are frowned upon (at least in my office) however we make an exception for the Game Instance class because you’d never change Game Instance during run time, which is what would otherwise make pure-casts so unreliable.
what is the complete picture here like? for example you mention you are using a widget and a binding therein but you dont show it so that could be part of the issue. also if you are using a widget and binding then why have you made variables in both the game mode and the game instance its just as easy to reference one as the other? basically you can reduce some of the redundancy to make things simpler.
you basic logic seems solid in theory though id make a few modifications. you could use some thing like: on begin play of game mode → start timer by event/function | custom event-> get game instance, cast to identify → increment seconds / minutes variable. then you would just need a binding in the widget that gets game instance, gets the variables, and converts them to text.
one last thing, i would begin with getting the time system working without the added issue of the widget. so to start just print the variables value one tick via the print string node. then once that system works you can worry about the widget portion. id be a shame to have a widget issue and your trying to change the script instead (looking in the wrong place ya know).
The pure cast node doesn’t help for some reason, even after I put the sets after a delay, so I just moved the cast earlier and that works but the timer does still not function, I think i’ll ask another question on here because I’ve messed around so much for this I probably messed something up somewhere else
The widget blueprint is in one of the attached files on my other post, I didn’t want to continue this ‘thread’ as my question had been answered, but that’s a good idea I’ll hook it up to a print text or something.
I’ve found the problem, the casts always fails for some reason - any ideas?
omfg i just found the mistake (for some reason I didn’t change my project settings game instant) - now everything works thanks for ur help
haha sometimes its those simple things
in your picture your trying to get a variable from the cast which has yet to happen. you need a valid reference to a actor before you can access and set its variables.
I removed the gameinstance bit and just used the game mode blueprints variable s and that worked (thought won’t carry over as character resets I think?
the gamemode is destroyed between levels so nothing it contains will be saved. if you need to track a variable between levels the game instance is your best bet since it does not get destroyed.