Stop Game flow?

Hello,

I am wondering, for the end of the game once the objective of my game, in which case when everything is herded and the complete widget appears, I would like to know how to stop my timer/show the time the player took to complete the objective. I am using a widget to display the timer.

Also, when the complete widget appears, I would like to remove control over the third person character in this case would be a dog. That way when selecting one of the buttons with the mouse, the camera does not move like when in control of the character.

If someone can help me (with images) that would be great, thanks!

Many ways to do it, here’s a timer that is completely self-contained (for simplicity sake) in a single widget:


Here’s how it works:

  • create the widget when the activity starts and add it to the viewport
  • the widget is hidden but its internal timer keeps accumulating
  • use MaxTime to show it automagically after X seconds (perhaps there’s a time limit in your game!)
  • or set MaxTime to a huge value to run it indefinitely
  • call Activity Complete event to show the time elapsed and Unpossess to remove Character control
  • alternatively, have another actor in the level with a camera and Set View Target with Blend to switch cameras - perhaps you want a nice aerial shot of the level once the player is done playing

Alright, I can’t create custom events in my timer widget(???)

Why not? Right click the graph and create a custom event.

I created the code like displayed
above although I couldn’t find the
same set timer handle

The Timer Handle is a variable. You can create one by disconnecting Return Value of the Set Timer node, right clicking that pin and Promote to Variable - this will automagically create a var of the correct type.

when I start the game the timer is not
being displayed

How are you adding this widget to the screen? Besides that, the timer starts Hidden and only shows when the time has elapsed or you call Activity Complete.

Either set MaxTime to a non-zero value (in seconds) or do not hide the timer when the widget gets Constructed.

Ah! Sorry, wasn’t working in the event graph. That’s why it wasn’t allowing custom events to be made.

Anyways, I created the code like displayed above although I couldn’t find the same set timer handle and now when I start the game the timer is not being displayed(???)

The timer is displayed in the third person game mode and I now I have the code implemented but I do not see the timer stop when another widget is displayed as the end of my game

I do not see the timer stop when
another widget is displayed as the end
of my game

Call Activity Complete to stop the timer. I did not test it too much, I’ll have a closer look in case you can’t get it to work.

Added a small delay before invalidating the timer as the timing is weird without it. It seems that the invalidation can happen before you read the timer. This is most likely a bug. Apart from that,it seems to work fine:

Image from Gyazo

The problem is, I want the time that is displayed through out the game to stop and not just be displayed at the end. Like in racing games or something where you can keep track of the time while the player goes.

So don’t hide the timer - skip the 2nd node in the my example.

Hey, which node are you referring to? The set visibility node? I completely skipped both of them

And the timer I have going, does not stop

Edit: I notice you also changed the time in your example from a node to 500

The script is taken from a working example demonstrated above and works as is. Not sure what else you’ve got going on elsewhere.


Apart from that, yours is not wired the same as mine, you invalidate the timer handle as soon as you start it - the node in upper right corner executes immediately.


And the timer I have going, does not
stop

How do you call ActivityComplete?

The ActivityComplete is a custom event in the timer widget. You need to call it to stop the timer.

How would I call it? I have it connected to un possess, if that’s what you mean

Ah, I see what you mean about my invalidate timer handle.

How do you call ActivityComplete?

What do you mean?

I am wondering, for the end of the
game once the objective of my game, in
which case when everything is herded
and the complete widget appears

You start the timer at the beginning of the game. When you finish the herding thing, you access the widget that has the timer and tell it (call the event) Activity Complete - it will then execute whatever it is connected to - the event will start stepping through the white wire execution chain.

It’s one thing to have an event and another to actually activate / evoke it - call it. How would your game know when to stop the timer? You need to send the message to the widget and tell it what and when to do.

This functionality is encapsulated in the Activity Complete custom event you created.


Think of a trigger that tells your game the Herding task has been completed; at this point you should access the reference to the widget and call the appropriate event which will then execute the nodes it is connected to.

Could I use this in a gameinstance blueprint so it can go over levels, as I want it to save the time each level has taken for more than 1 level.

Yes, you can.