edited May 2017 in ORK Support
is there an easy way for the player to cancel events part way through execution?

my specific use case is that i'm displaying a short looped video (in reality a sequence of pre-rendered still images) that i display using a chain of Show Image/Wait events

at the moment the player has to watch the whole sequence, but i really want to set it up so that he can press the cancel key at any point while it's playing and end the event

i remember also thinking some while back when i was walking through the tutorials, that it would be a useful thing to be able to do during cut scenes (where the games writer always wants the player to purleeeese look at the thing they've spent all those hours creating, but the player usually just wants to get on and play the game...)

if there's no easy way to do it from within the event system itself, then is there a way to do it from script? ideally i'd want to terminate the event gracefully, by running a further event that fades out the mini movie, but simply crashing out of it would be ok too
Post edited by HarryOminous on
  • edited May 2017
    on reflection, i think (although i haven't actually tried it yet) that i can see how to do it in code - simply move the Show Image/Wait steps out of the event system and into their own script (although, i'm not entirely sure how to do that), and then listen out for the user pressing the cancel key. that would also have the advantage that i could generalise the functionality by passing the image sequence in via a public array rather than (as now) having them hard coded in each movie display event


    i'd still be interested to know if there's any other way to cancel an event though
    Post edited by HarryOminous on
  • If the event interaction has Stop On Destroy enabled, you can stop the event by destroying the interaction's game object.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited May 2017
    ok, thanks, that pointed me in the right direction

    i didn't actually want to destroy the interaction's game object, because it was used to display the movie whenever the player interacts with it

    what i've done, therefore, is to split the events from the original interaction object into two parts, with one part to query if the player wants to view the movie, and another part to actually display it. i then save that second part in a prefab (with a Start Type of Autostart) which the trigger event instantiates

    when the movie starts up, i create a couple of variables to let me know it's running and also if it was automatically stopped (i.e. it displayed to the end without interruption)

    a small bit of code continually listens out to check if it's running, and whether the player has pressed cancel, or the movie has run to completion. and, if either of those last two is true, it destroys the prefab, thus terminating the movie (but allowing it to be played again at some point)

    i got it mostly working but then had some problems because i wanted the movie display to block any player/camera movement, and i guess that destroying the prefab meant that those blocks wouldn't get cleared? anyway, in practise that meant that the event could be interrupted, and the event was then terminated, but after that the main game menu could no longer be invoked (although, the player could still be moved)

    in the end, pretty much in desperation, i removed the blocks in the Play event itself and ticked "In Blocked Control" in the prefab's Interaction Event, and that... seemed to do the trick

    now the player can fire up the movie any time he wants, then watch it to completion, or cancel it if he gets bored. now that i know how to do it i'll be using this technique for other similar situations where i want the player to be able to cancel out of some ongoing event
    Post edited by HarryOminous on
  • In case you own Makinom - you have more control over this in Makinom schematics :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • i'm thinking about getting makinom at some point, but i really want to get my current project done and dusted before i do anything else

    (unfortunately, like alice climbing the hill, the further i get, the further away from the summit i seem to be)
Sign In or Register to comment.